Search Results

Search found 7401 results on 297 pages for 'gcc warning'.

Page 16/297 | < Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • gcc - using -werror and -std= -pedantic considered good practice?

    - by Helper Method
    I'm just digging into the gcc manual and some things are still unclear to me: a) When specifying a std, should I always use -pedantic in conjunction? b) When using -g, it the standard level sufficient or should I specify level 3, i.e. -g3? c) Is it good practice to use -Werror to promote all warnings to errors and -pedantic-errors to promote all pedantic warnings to errors?

    Read the article

  • Mixing libraries with and without RTTI with GCC on Mac OS X?

    - by Steve the Plant
    I've been banging my head on an issue and before I continue injuring myself some more, I'd like to confirm: Is it possible to have a GCC project that uses libraries that are compiled with and without RTTI? So, for example, I have project A (compiled without RTTI) that uses library B (compiled with RTTI) and library C (compiled without RTTI). In theory, is all that supposed to compile and link with no problems?

    Read the article

  • gcc optimization? bug? and its practial implication to project

    - by kumar_m_kiran
    Hi All, My questions are divided into three parts Question 1 Consider the below code, #include <iostream> using namespace std; int main( int argc, char *argv[]) { const int v = 50; int i = 0X7FFFFFFF; cout<<(i + v)<<endl; if ( i + v < i ) { cout<<"Number is negative"<<endl; } else { cout<<"Number is positive"<<endl; } return 0; } No specific compiler optimisation options are used or the O's flag is used. It is basic compilation command g++ -o test main.cpp is used to form the executable. The seemingly very simple code, has odd behaviour in SUSE 64 bit OS, gcc version 4.1.2. The expected output is "Number is negative", instead only in SUSE 64 bit OS, the output would be "Number is positive". After some amount of analysis and doing a 'disass' of the code, I find that the compiler optimises in the below format - Since i is same on both sides of comparison, it cannot be changed in the same expression, remove 'i' from the equation. Now, the comparison leads to if ( v < 0 ), where v is a constant positive, So during compilation itself, the else part cout function address is added to the register. No cmp/jmp instructions can be found. I see that the behaviour is only in gcc 4.1.2 SUSE 10. When tried in AIX 5.1/5.3 and HP IA64, the result is as expected. Is the above optimisation valid? Or, is using the overflow mechanism for int not a valid use case? Question 2 Now when I change the conditional statement from if (i + v < i) to if ( (i + v) < i ) even then, the behaviour is same, this atleast I would personally disagree, since additional braces are provided, I expect the compiler to create a temporary built-in type variable and them compare, thus nullify the optimisation. Question 3 Suppose I have a huge code base, an I migrate my compiler version, such bug/optimisation can cause havoc in my system behaviour. Ofcourse from business perspective, it is very ineffective to test all lines of code again just because of compiler upgradation. I think for all practical purpose, these kinds of error are very difficult to catch (during upgradation) and invariably will be leaked to production site. Can anyone suggest any possible way to ensure to ensure that these kind of bug/optimization does not have any impact on my existing system/code base? PS : When the const for v is removed from the code, then optimization is not done by the compiler. I believe, it is perfectly fine to use overflow mechanism to find if the variable is from MAX - 50 value (in my case).

    Read the article

  • C++: Why does gcc prefer non-const over const when accessing operator[]?

    - by JonasW
    This question might be more appropriately asked regarding C++ in general, but as I am using gcc on linux that's the context. Consider the following program: #include <iostream> #include <map> #include <string> using namespace std; template <typename TKey, typename TValue> class Dictionary{ public: map<TKey, TValue> internal; TValue & operator[](TKey const & key) { cout << "operator[] with key " << key << " called " << endl; return internal[key]; } TValue const & operator[](TKey const & key) const { cout << "operator[] const with key " << key << " called " << endl; return internal.at(key); } }; int main(int argc, char* argv[]) { Dictionary<string, string> dict; dict["1"] = "one"; cout << "first one: " << dict["1"] << endl; return 0; } When executing the program, the output is: operator[] with key 1 called operator[] with key 1 called first one: one What I would like is to have the compiler choose the operator[]const method instead in the second call. The reason is that without having used dict["1"] before, the call to operator[] causes the internal map to create the data that does not exist, even if the only thing I wanted was to do some debugging output, which of course is a fatal application error. The behaviour I am looking for would be something like the C# index operator which has a get and a set operation and where you could throw an exception if the getter tries to access something that doesn't exist: class MyDictionary<TKey, TVal> { private Dictionary<TKey, TVal> dict = new Dictionary<TKey, TVal>(); public TVal this[TKey idx] { get { if(!dict.ContainsKey(idx)) throw KeyNotFoundException("..."); return dict[idx]; } set { dict[idx] = value; } } } Thus, I wonder why the gcc prefers the non-const call over the const call when non-const access is not required.

    Read the article

  • How to resolve include file names conflicts in GCC?

    - by actual
    I have two header files named string.h in different libraries, they are conflicted with each other and even conflicted with standard C include file of the same name. There is no need to use any string.h except standard one, but I need to include libraries headers paths in GCC search path. Currently I use something like -I /usr/local/include/lib1 -I /usr/local/include/lib2, but that way I can not include standard C string.h. What is the right way to resolve such conflicts?

    Read the article

  • Clang warning flags for Objective-C development

    - by Macmade
    As a C & Objective-C programmer, I'm a bit paranoid with the compiler warning flags. I usually try to find a complete list of warning flags for the compiler I use, and turn most of them on, unless I have a really good reason not to turn it on. I personally think this may actually improve coding skills, as well as potential code portability, prevent some issues, as it forces you to be aware of every little detail, potential implementation and architecture issues, and so on... It's also in my opinion a good every day learning tool, even if you're an experienced programmer. For the subjective part of this question, I'm interested in hearing other developers (mainly C, Objective-C and C++) about this topic. Do you actually care about stuff like pedantic warnings, etc? And if yes or no, why? Now about Objective-C, I recently completely switched to the LLVM toolchain (with Clang), instead of GCC. On my production code, I usually set this warning flags (explicitly, even if some of them may be covered by -Wall): -Wall -Wbad-function-cast -Wcast-align -Wconversion -Wdeclaration-after-statement -Wdeprecated-implementations -Wextra -Wfloat-equal -Wformat=2 -Wformat-nonliteral -Wfour-char-constants -Wimplicit-atomic-properties -Wmissing-braces -Wmissing-declarations -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wnewline-eof -Wold-style-definition -Woverlength-strings -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type -Wsequence-point -Wshadow -Wshorten-64-to-32 -Wsign-compare -Wsign-conversion -Wstrict-prototypes -Wstrict-selector-match -Wswitch -Wswitch-default -Wswitch-enum -Wundeclared-selector -Wuninitialized -Wunknown-pragmas -Wunreachable-code -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wwrite-strings I'm interested in hearing what other developers have to say about this. For instance, do you think I missed a particular flag for Clang (Objective-C), and why? Or do you think a particular flag is not useful (or not wanted at all), and why?

    Read the article

  • Netbook performs hard shutdown without warning on low battery power

    - by Steve Kroon
    My Asus EEE netbook performs a hard shutdown when it reaches low battery power, without giving any warning - i.e. the power just goes off, without any shutdown process. I can't find anything in the syslog, and no error messages are printed before it happens. I've had this problem on previous (K)Ubuntu versions, and hoped updating to Ubuntu Precise would help resolve the issue, but it hasn't. The option in the Power application for "when power is critically low" is currently blank - the only options are a (grayed-out) hibernate and "Power off". I have re-installed indicator-power to no effect. The time remaining reported by acpi is unstable, as is the time remaining reported by gnome-power-statistics. (For example, running acpi twice in succession, I got 2h16min, and then 3h21min remaining. These sorts of jumps in the remaining time are also in the gnome-power-statistics graphs.) It might be possible to write a script to give me advance warning (as per @RanRag's comment below), but I would prefer to isolate why I don't get a critical battery notification from the system before this happens, so that I can take action as appropriate (suspend/shutdown/plug in power) when I get a notification. Some additional information on the battery: kroon@minia:~$ upower -i /org/freedesktop/UPower/devices/battery_BAT0 native-path: /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/PNP0C0A:00/power_supply/BAT0 vendor: ASUS model: 1005P power supply: yes updated: Fri Aug 17 07:31:23 2012 (9 seconds ago) has history: yes has statistics: yes battery present: yes rechargeable: yes state: charging energy: 33.966 Wh energy-empty: 0 Wh energy-full: 34.9272 Wh energy-full-design: 47.52 Wh energy-rate: 3.7692 W voltage: 12.61 V time to full: 15.3 minutes percentage: 97.248% capacity: 73.5% technology: lithium-ion History (charge): 1345181483 97.248 charging 1345181453 97.155 charging 1345181423 97.062 charging 1345181393 96.970 charging History (rate): 1345181483 3.769 charging 1345181453 3.899 charging 1345181423 4.061 charging 1345181393 4.201 charging kroon@minia:~$ cat /proc/acpi/battery/BAT0/state present: yes capacity state: ok charging state: charging present rate: 332 mA remaining capacity: 3149 mAh present voltage: 12612 mV kroon@minia:~$ cat /proc/acpi/battery/BAT0/info present: yes design capacity: 4400 mAh last full capacity: 3209 mAh battery technology: rechargeable design voltage: 10800 mV design capacity warning: 10 mAh design capacity low: 5 mAh cycle count: 0 capacity granularity 1: 44 mAh capacity granularity 2: 44 mAh model number: 1005P serial number: battery type: LION OEM info: ASUS

    Read the article

  • WARNING Retrying Bulk Insert for file:sqlldr due to Communication Error:256

    - by user702295
    WARNING Retrying Bulk Insert for file:sqlldr due to Communication Error:256 I am running my engine on Linux and am receiving an intermittent message "WARNING Retrying bulk insert for file: sqlldr due to communication Error: 256" The engine seems to have completed successfully, but it is not clear if this error caused some of the forecast to not complete. It is also not clear what caused the error. Generally if you see only the WARNING of it, it means that next retries of the same load request have eventually succeeded and so the run a a whole is not affected. In order to know more about what happens, look for .log/.bad files left in the engines bin directory or possibly a quote of them within the specific engine log that had the issue.  The sqlnet.log file may also have some information about it and perhaps at the database server side there may be some log/alert regarding what happened.  Look at the alert.log. In general it could be that the database server/network was over loaded at the time and somehow the connection was rejected/failed/aborted either due to specific setting on concurrent connections/sessions or inadvertently due to glitch in network/os/hardware. If this repeats and becomes more frequent during the run you should look further into it as mentioned above. You can also track this using either SQL*Trace or java.util.logging.  - Globally enable logging by setting the oracle.jdbc.Trace system property java -Doracle.jdbc.Trace=true - Client Side Tracing: Your SQLNET.ORA file should contain the following lines to produce a client side trace file: trace_level_client = 10 trace_unique_client = on trace_file_client = sqlnet.trc trace_directory_client = <path_to_trace_dir> Server Side Tracing: To enable server side tracing, use the following parameters: trace_level_server = 10 trace_file_server = server.trc trace_directory_server = <path_to_trace_dir> Tracing Levels: The following values can be used for TRACE_LEVEL* parameters:     16 or SUPPORT — WorldWide Customer Support trace information     10 or ADMIN — Administration trace information     4 or USER — User trace information     0 or OFF — no tracing, the default Additional information is readily available via the web.

    Read the article

  • C printf not working on ubuntu 13.10 terminal

    - by Blaze Tama
    First, im new in ubuntu so please bear with me. I need to create a C based program for a course in my university. I was using opensuse and its konsole when i was in the university's lab. So basically i need to install opensuse on my system or using a vmware. But i feel lazy to do that, so i tried to run it on my ubuntu instead of opensuse. However, no C code seems working on ubuntu's terminal. The compiling is success, but its not running, or at least the printf is not running. This is my code, a very very simple one : #include<stdio.h> #include<unistd.h> #include<stdlib.h> int main() { printf("test"); return 0; } When i compile it with gcc test.c -o test everything work fine and i get an executeable file. Then i try to run it by ./test, but the printf is not printed. No error or warning was shown. Am i missing something? Note : my gcc is the new one, it should has no problem. Thanks for your help :D

    Read the article

  • Install newer version of GCC in Knoppix

    - by Z boson
    I have Knoppix 7.30 installed on a USB with a persistent file. It comes with GCC 4.7.2. I would like to install GCC 4.9.x or 4.8.x. Being that Knopppix is based on Debian I would normally do something like apt-get upgrade But as far as I understand it's not recommended to do this with Knoppix. Warning: apt-get upgrade is a BAD IDEA. It will, quite probably, render your KNOPPIX remaster unbootable, or broken in some way. A far safer method is to only upgrade packages as necessary. I can say from experience that that is the cse. So how should I go about installing GCC 4.9? Another option would be to "remaster" knoppix to use GCC 4.9 by default rather than install it with a persistent file. I would be happy with either solution.

    Read the article

  • compiler warning at C++ template base class

    - by eike
    I get a compiler warning, that I don't understand in that context, when I compile the "Child.cpp" from the following code. (Don't wonder: I stripped off my class declarations to the bare minuum, so the content will not make much sense, but you will see the problem quicker). I get the warning with VS2003 and VS2008 on the highest warning level. The code AbstractClass.h : #include <iostream> template<typename T> class AbstractClass { public: virtual void Cancel(); // { std::cout << "Abstract Cancel" << std::endl; }; virtual void Process() = 0; }; //outside definition. if I comment out this and take the inline //definition like above (currently commented out), I don't get //a compiler warning template<typename T> void AbstractClass<T>::Cancel() { std::cout << "Abstract Cancel" << std::endl; } Child.h : #include "AbstractClass.h" class Child : public AbstractClass<int> { public: virtual void Process(); }; Child.cpp : #include "Child.h" #include <iostream> void Child::Process() { std::cout << "Process" << std::endl; } The warning The class "Child" is derived from "AbstractClass". In "AbstractClass" there's the public method "AbstractClass::Cancel()". If I define the method outside of the class body (like in the code you see), I get the compiler warning... AbstractClass.h(7) : warning C4505: 'AbstractClass::Cancel' : unreferenced local function has been removed with [T=int] ...when I compile "Child.cpp". I do not understand this, because this is a public function and the compiler can't know if I later reference this method or not. And, in the end, I reference this method, because I call it in main.cpp and despite this compiler warning, this method works if I compile and link all files and execute the program: //main.cpp #include <iostream> #include "Child.h" int main() { Child child; child.Cancel(); //works, despite the warning } If I do define the Cancel() function as inline (you see it as out commented code in AbstractClass.h), then I don't get the compiler warning. Of course my program works, but I want to understand this warning or is this just a compiler mistake? Furthermore, if do not implement AbsctractClass as a template class (just for a test purpose in this case) I also don't get the compiler warning...?

    Read the article

  • Problem with GCC calling static templates functions in templated parent class.

    - by Adisak
    I have some code that compiles and runs on MSVC++ but will not compile on GCC. I have made a test snippet that follows. My goal was to move the static method from BFSMask to BFSMaskSized. Can someone explain what is going on with the errors (esp. the weird 'operator<' error)? Thank you. In the case of both #defines are 0, then the code compiles on GCC. #define DOESNT_COMPILE_WITH_GCC 0 #define FUNCTION_IN_PARENT 0 I get errors if I change either #define to 1. Here are the errors I see. #define DOESNT_COMPILE_WITH_GCC 0 #define FUNCTION_IN_PARENT 1 Test.cpp: In static member function 'static typename Snapper::BFSMask<T>::T_Parent::T_SINT Snapper::BFSMask<T>::Create_NEZ(TCMP)': Test.cpp(492): error: 'CreateMaskFromHighBitSized' was not declared in this scope #define DOESNT_COMPILE_WITH_GCC 1 #define FUNCTION_IN_PARENT 0 Test.cpp: In static member function 'static typename Snapper::BFSMask<T>::T_Parent::T_SINT Snapper::BFSMask<T>::Create_NEZ(TCMP) [with TCMP = int, T = int]': Test.cpp(500): instantiated from 'TVAL Snapper::BFWrappedInc(TVAL, TVAL, TVAL) [with TVAL = int]' Test.cpp(508): instantiated from here Test.cpp(490): error: invalid operands of types '<unresolved overloaded function type>' and 'unsigned int' to binary 'operator<' #define DOESNT_COMPILE_WITH_GCC 1 #define FUNCTION_IN_PARENT 1 Test.cpp: In static member function 'static typename Snapper::BFSMask<T>::T_Parent::T_SINT Snapper::BFSMask<T>::Create_NEZ(TCMP) [with TCMP = int, T = int]': Test.cpp(500): instantiated from 'TVAL Snapper::BFWrappedInc(TVAL, TVAL, TVAL) [with TVAL = int]' Test.cpp(508): instantiated from here Test.cpp(490): error: invalid operands of types '<unresolved overloaded function type>' and 'unsigned int' to binary 'operator<' Here is the code namespace Snapper { #define DOESNT_COMPILE_WITH_GCC 0 #define FUNCTION_IN_PARENT 0 // MASK TYPES // NEZ - Not Equal to Zero #define BFSMASK_NEZ(A) ( ( A ) | ( 0 - A ) ) #define BFSELECT_MASK(MASK,VTRUE,VFALSE) ( ((MASK)&(VTRUE)) | ((~(MASK))&(VFALSE)) ) template<typename TVAL> TVAL BFSelect_MASK(TVAL MASK,TVAL VTRUE,TVAL VFALSE) { return(BFSELECT_MASK(MASK,VTRUE,VFALSE)); } //----------------------------------------------------------------------------- // Branch Free Helpers template<int BYTESIZE> struct BFSMaskBase {}; template<> struct BFSMaskBase<2> { typedef UINT16 T_UINT; typedef SINT16 T_SINT; }; template<> struct BFSMaskBase<4> { typedef UINT32 T_UINT; typedef SINT32 T_SINT; }; template<int BYTESIZE> struct BFSMaskSized : public BFSMaskBase<BYTESIZE> { static const int SizeBytes = BYTESIZE; static const int SizeBits = SizeBytes*8; static const int MaskShift = SizeBits-1; typedef typename BFSMaskBase<BYTESIZE>::T_UINT T_UINT; typedef typename BFSMaskBase<BYTESIZE>::T_SINT T_SINT; #if FUNCTION_IN_PARENT template<int N> static T_SINT CreateMaskFromHighBitSized(typename BFSMaskBase<N>::T_SINT inmask); #endif }; template<typename T> struct BFSMask : public BFSMaskSized<sizeof(T)> { // BFSMask = -1 (all bits set) typedef BFSMask<T> T_This; // "Import" the Parent Class typedef BFSMaskSized<sizeof(T)> T_Parent; typedef typename T_Parent::T_SINT T_SINT; #if FUNCTION_IN_PARENT typedef T_Parent T_MaskGen; #else typedef T_This T_MaskGen; template<int N> static T_SINT CreateMaskFromHighBitSized(typename BFSMaskSized<N>::T_SINT inmask); #endif template<typename TCMP> static T_SINT Create_NEZ(TCMP A) { //ReDefineType(const typename BFSMask<TCMP>::T_SINT,SA,A); //const typename BFSMask<TCMP>::T_SINT cmpmask = BFSMASK_NEZ(SA); const typename BFSMask<TCMP>::T_SINT cmpmask = BFSMASK_NEZ(A); #if DOESNT_COMPILE_WITH_GCC return(T_MaskGen::CreateMaskFromHighBitSized<sizeof(TCMP)>(cmpmask)); #else return(CreateMaskFromHighBitSized<sizeof(TCMP)>(cmpmask)); #endif } }; template<typename TVAL> TVAL BFWrappedInc(TVAL x,TVAL minval,TVAL maxval) { const TVAL diff = maxval-x; const TVAL mask = BFSMask<TVAL>::Create_NEZ(diff); const TVAL incx = x + 1; return(BFSelect_MASK(mask,incx,minval)); } SINT32 currentsnap = 0; SINT32 SetSnapshot() { currentsnap=BFWrappedInc<SINT32>(currentsnap,0,20); return(currentsnap); } }

    Read the article

  • Adding icon to gcc executable and opening in terminal.

    - by sfactor
    I made a program to connect to a device via Bluetooth and send the data to the web using pure C in gcc. I won't be able to implement any GUI portion in the code right now but I need to deploy it to test users for testing. I want to have the executable with an icon so that a user can click on the executable and the program starts in the terminal. How do I add an icon to the executable and start the program in the terminal? Sorry I failed to mention before that its in Ubuntu Linux

    Read the article

  • how to raise warning if return value is disregarded - gcc or static code check?

    - by Drakosha
    I'd like to see all the places in my code (C++) which disregard return value of a function. How can I do it - with gcc or static code analysis tool? Bad code example: int f(int z) { return z + (z*2) + z/3 + z*z + 23; } int main() { int i = 7; f(i); ///// <<----- here I disregard the return value return 1; } Update: it should work even if the function and its use are in different files free static check tool

    Read the article

  • Count function calls by name or signature. Gcc, C++

    - by MajesticRa
    I have some c++ written package. Linux, gcc. I can modify compilation process (change Makefile, flags, etc.), but can not change C++ source code. One runs the package with different parameters, it does a job and exits. How to count: 1) Number of calls of function with specific name? 2) Number of calls of functions with specific signature? 3) Number of calls of functions where one of the parameters is of specific type i.e. std::string (type is specified by signature)? 4) and extra Number of calls of functions of STL objects, i.e. std::string copy constructor? (I mean count a number of calls during the run. ) I thought to do it with GDB, but I found it very tough to do (1) and have not found how to do (2)-(4) at all. All acceptable answers I will write here for humanity.

    Read the article

  • Cross compilation of udns for power pc

    - by pragya
    I have libraries of x86 architecture that I want to cross compile for power pc. I have already cross compiled different libraries for power pc by setting environment variables for powerpc and using appropriate options with ./configure. Now, I want to cross compile libudns for powerpc. In ./configure --help I am not getting those appropriate options to cross compile. For libudns, I set environment variables for powerpc and ran ./configure but it throws following error: configure: fatal: $CC (powerpc-linux-gnu-gcc) is not a working compiler

    Read the article

  • makeMKV setup error

    - by PitaJ
    When I run sudo bash configure (./configure doesn't work), I get this: checking whether we are cross compiling... configure: error: in /media/pitaj/Shared/Documents/makeMKV/makemkv-oss': configure: error: cannot run C compiled programs. If you meant to cross compile, use --host'. See `config.log' for more details In console.log, it says that gcc -V isn't valid I'm following this tutorial: http://www.makemkv.com/forum2/viewtopic.php?f=3&t=224

    Read the article

  • In Linux, is there a way to get a warning if I forget to unplug my pendrive?

    - by missingno
    I forgot my pendrive plugged in when leaving the computer lab yesterday, and I would have lost it if it wasn't for a kind soul finding and returning it. I want to avoid this in the future and apparently there are some tools you can use in windows that warn you if you are leaving a pendrive behind when logging off or shutting down the computer. Is there anything similar that works on Linux? I need this to work on Fedora 17 (GNOME 3 shell), and preferably without requiring administrator privileges.

    Read the article

  • Gtk warning when opening Gedit in terminal

    - by dellphi
    Previously, I need to clear documents history, so I Googled and found this: http://www.watchingthenet.com/ubuntu-tip-clear-disable-recent-documents.html I did the step, and then when I opened gedit in root terminal, I've got this: root@dellph1-desktop:/# gedit (gedit:8224): GLib-CRITICAL **: g_bookmark_file_load_from_data: assertion `length != 0' failed (gedit:8224): Gtk-WARNING **: Attempting to store changes into `/root/.recently-used.xbel', but failed: Failed to rename file '/root/.recently-used.xbel.FP7PPV' to '/root/.recently-used.xbel': g_rename() failed: Operation not permitted (gedit:8224): Gtk-WARNING **: Attempting to set the permissions of `/root/.recently-used.xbel', but failed: Operation not permitted root@dellph1-desktop:/# And it's happpened in user terminal: dellph1@dellph1-desktop:~$ gedit (gedit:9408): Gtk-CRITICAL **: gtk_accel_label_set_accel_closure: assertion `gtk_accel_group_from_accel_closure (accel_closure) != NULL' failed dellph1@dellph1-desktop:~$ I really hope someone helps in this case, thank you.

    Read the article

< Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >