gcc-warning

I have having following warning in gcc compilation in 32 bit architecture but not having any such warning in 64 bit architecture.

symbol.c: In function 'symbol_FPrint': symbol.c:1209: warning: format '%ld' expects type 'long int', but argument 3 has type 'SYMBOL' symbol.c: In function 'symbol_FPrintOtter': symbol.c:1236: warning: format '%ld' expects type 'long int', but argument 3 has type 'SYMBOL' symbol.c:1239: warning: format '%ld' expects type 'long int', but...

I have a following gcc compilation warning

symbol.h:179: note: expected ‘uintptr_t *’ but argument is of type ‘PRECEDENCE’ The corresponding code is : 176 void symbol_SetCount(SYMBOL, unsigned long); 177 unsigned long symbol_GetCount(SYMBOL); 178 179 size_t symbol_Ordering(uintptr_t*, SYMBOL); 180 181 void symbol_CheckIndexInRange(int); 182...

Conflicting PACKAGE_NAME and other macros when using autotools.

When using autotools (with a config.h file) for both a library, and a software built on that library, the compiler complains about a redefinition of some macros (PACKAGE_NAME, PACKAGE_TARNAME and so on). How can I prevent this? The config.h file is needed in the library to propagate it's setting to the software that use it. Right now ...

Why gcc4 warn and how to avoid it

I have a function declared as: void event_add_card (EventAddr addr, EventType type, unsigned char card); and union typedef union EventData { float money; /**< money info */ unsigned char card; /**< new card */ } EventData; When i compile following code: EventData data = {}; event_add_card (0,0, d...

Help with these warnings. [inheritance].

Hello there. I have a set of code, which mimics a basic library cataloging system. There is a base class named items, in which the the general id,title and year variables are defined and 3 other derived classes (DVD,Book and CD). Base [Items] Derived [DVD,Book,CD]. The programs runs, however I get the following warnings, I'm not sure ...

Why doesn't GCC produce a warning when assigning a signed literal to an unsigned type?

Several questions on this website reveal pitfalls when mixing signed and unsigned types and most compilers seem to do a good job about generating warnings of this type. However, GCC doesn't seem to care when assigning a signed constant to an unsigned type! Consider the following program: /* foo.c */ #include <stdio.h> int main(void) {...

Make errors - can the gcc compiler warnings prevent a C file from being compiled into an object file?

I'm trying to compile a wireless network card driver for my Linux box and I ran into a problem with the Make command. During the compilation process I normally see warnings on some of the C files that being are compiled; despite the warnings these files were still able to be compiled to an object file. When the Make process comes to a f...

C++: warning: '...' declared with greater visibility than the type of its field '...::<anonymous>'

I'm getting these two warnings (with GCC 4.2 on MacOSX): /Users/az/Programmierung/openlierox/build/Xcode/../../src/main.cpp:154:0 /Users/az/Programmierung/openlierox/build/Xcode/../../src/main.cpp:154: warning: 'startMainLockDetector()::MainLockDetector' declared with greater visibility than the type of its field 'startMainLockDetector(...

What is the explanation for "warning: assuming that the loop is not infinite"

I had just taken the decision to change as many variables from unsigned to int and upon recompiling the code in question, was greeted by this warning message: freespace_state.c:203: warning: assuming that the loop is not infinite The line in question: for (x = startx; x <= endx; ++x, ++xptr) This loop is 60 lines of code (inc white...

Fixing "comparison is always false ..." warning in GCC.

I'm having a problem which I'm sure is simple to fix but I'm at a loss... I have a template that performs the following code: T value = d; if ( std::numeric_limits< T >::is_signed ) { if ( value < 0 ) { *this += _T( "-" ); value = -(signed)value; } } Now for, obvious reasons, GCC is giving me a warning...

doubt regarding operations on "int" flavors

Hi, I am having following doubt regarding "int" flavors (unsigned int, long int, long long int). When we do some operations(* , /, + , -) between int and its flavors (lets say long int) in 32bit system and 64bit system is the implicit typecast happen for "int" for example :- int x ; long long int y = 2000; x = y ; (Higher is assigne...

How to eliminate external lib/third party warnings in GCC

Hi everyone, In the software project I'm working on, we use certain 3rd party libraries which, sadly, produce annoying gcc warnings. We are striving to clean all code of warnings, and want to enable the treat-warnings-as-errors (-Werror) flag in GCC. Is there a way to make these 3rd party generated warnings, which we cannot fix, to disa...

Remove first char of string C

Im trying to remove the first char of the string and keep the remainder, my current code doesnt compile and im confused on how to fix it. My code: char * newStr (char * charBuffer) { int len = strlen(charBuffer); int i = 1; char v; if(charBuffer[0] == 'A' || charBuffer[0] == 'Q'){ for(i=1;i<len;i++) ...

gcc warning: braces around scalar initializer

Hi Guys, I have look-up-table as defined below and I'm making use of GCC. When I compile I get warnings as warning: braces around scalar initializer What does this warning mean? How should I initialize this LUT? Am I making a mistake in initializing this structures? Help!! typedef struct TECH { float velocity1, velocity2; ...

gcc-4.2 failed with xcode 1

I have started learning opengl es. I downloaded code from the companion website, but I cannot compile any project. When I use simulator 4.0 as base SDK, I get the message /Developer/Platform/iPhoneSimulator/Platform/Developer/user/bin/gcc-4.2 failed with exit code 1. However, whet I use device 4.0 as base SDK, I am getting the message...

Signed / unsigned comparison and -Wall

I have recently started using the -Wall compiler switch in an attempt to improve the quality of my code. It is giving (correctly) a warning about this little snippet... int i; for (i = start - 1; i >= 0; i--) { if (i >= number1.array.size()) { one_value = 0; } because number1.array.size...

How to supress known warnings when building Nginx on Linux?

I am a linux amateur and am trying to build nginx on Debian (Lenny) for the first time. Attemps to build nginx are failing and I receive the known warnings on sys_errorlist and sys_nerr as documented here: http://nginx.org/en/docs/sys_errlist.html The documentation suggests this is a warning that I can ignore. My question is what fl...

g++ warning: comparison of unsigned expression < 0 is always false

To compile my C++ code I use the -W flag, which causes the warning: warning: comparison of unsigned expression < 0 is always false I believe this was considered as a bug and was fixed on version GCC 4.3, but I'm using GCC 4.1 Code that is obviously offending here: void FieldGroup::generateCreateMessage (const ApiEvent::GroupData ...

unused parameter warnings in C code

What's the best way to suppress "unused parameter" warning in C code. For instance, Bool NullFunc(const struct timespec *when, const char *who, unsigned short format, void *data, int len) { return TRUE; } In C++ I was able to put /.../ around the parameters. But not in C of course. It gives me "error: parameter name omitted". So...

Casting to void doesn't remove warn_unused_result error

In a test, I'm discarding anything from stderr since it clutters the output of the test case. I'm using the following code: freopen("/dev/null", "w", stderr); When compiling with -Wall -Werror, I get the error error: ignoring return value of ‘freopen’, declared with attribute warn_unused_result which is expected. However, the usual...