gcc-warning

Make one gcc warning an error?

I get this warning from GCC: warning: cannot pass objects of non-POD type 'class Something' through '...'; call will abort at runtime It's pretty deadly, especially since it calls an abort. Why isn't this an error? I would like to make it an error, but: How do I make a specific warning an error? Which warning is it? According to ...

Is there any way to get readable gcc error and warning output at the command line?

For some long errors, the gcc output is dense and has lots of line-wrapping etc. Especially when errors are subtle, it can take me 10-30 seconds of squinting to parse it with my eyes. I've taken to pasting this in an open code-editor window to get some basic syntax highlighting and enable reformatting with regex's. Has anyone invented...

warning: the use of `mktemp' is dangerous

Hello! How can I suppress following warning from gcc linker: warning: the use of mktemp' is dangerous, better use mkstemp' I do know that it's better to use mkstemp() but for some reason I have to use mktemp() function. ...

How do I turn off erroneous float/long error messages from gcc.

I recently was making a change to to our codebase from float to long for some variables, and discovered that there were no error messages generated by the compiler in areas I knew were still wrong. This led me to add -Wconversion to the compiler flags. But, oops, this leads to some spurious error messages. In the snippet below, I get er...

suppress gcc warnings : "warning: this is the location of the previous definition"

Hi, I need a set of wrappers around the standard system calls-open,listen,etc. For these i have a few "#define" as in: #define open(a,b,c) JCL_Open(a,b,c) But when i compile the header and associated .c files, i am getting the following warning: /jcl_wrappers.h:114:1: warning: "open" redefined /jcl_wrappers.h:113:1: warning: this is ...

What does "Warning: return makes integer from pointer without a cast" mean in C?

I'm writing a simple function in C whose purpose is to take a 6 bit number, work out the first 3 bits, and based on that, return a "r", "w" or "o". However, when I compile I get this warning: 'return makes integer from pointer without a cast'. Then, when I run the program, I find that the function is returning a weird character that def...

Compile error related to "index"- is it actually a function?

I'm removing all warnings from our compile, and came across the following: warning: the address of ` char* index(const char*, int)', will always be 'true' for the following line of code: DEBUG_MSG("Data received from Device "<<(int)_nodeId << "for" << index <<(int)msgIn.index<<"."); DEBUG_MSG is one of our logging macros that th...

Disable gcc warning for incompatible options.

I'm curious if there is an option to disable gcc warnings about a parameter not being valid for the language being compiled. Ex: cc1: warning: command line option "-Wno-deprecated" is valid for C++/Java/ObjC++ but not for C Our build system passes the warnings we have decided on globally across a build. We have both C/C++ code and t...

warning: incompatible implicit declaration of built-in function ‘xyz’

I'm getting a number of these warnings when compiling a few binaries: warning: incompatible implicit declaration of built-in function ‘strcpy’ warning: incompatible implicit declaration of built-in function ‘strlen’ warning: incompatible implicit declaration of built-in function ‘exit’ To try to resolve this, I have added #include <...

How to suppress the "enumeral and non-enumeral type in conditional expression" warning in GCC

I keep getting this warning from a third-party library (which I don't want to debug), so I'd really appreciate a way to suppress this specific warning. Google failed me, so here I am. ...

Syntax hilighting for gcc warnings in bash

Is there a way to enable a hilighting scheme for gcc/g++ warning output? I'd like a simple way to spot (bright red?) warnings from my compiler as the messages are streaming by. ...

Pedantic gcc warning: type qualifiers on function return type

When I compiled my C++ code with GCC 4.3 for the first time, (after having compiled it successfully with no warnings on 4.1, 4.0, 3.4 with the -Wall -Wextra options) I suddenly got a bunch of errors of the form warning: type qualifiers ignored on function return type. Consider temp.cpp: class Something { public: const int getConstT...

How to type cast a literal in C

Hi, I have a small sample function: #define VALUE 0 int test(unsigned char x) { if (x>=VALUE) return 0; else return 1; } My compiler warns me that the comparison (x>=VALUE) is true in all cases, which is right, because x is an unsigned character and VALUE is defined with the value 0. So I changed my code to: if ( ((sign...

Is there an gcc/Xcode pragma to suppress warnings?

Is there a #pragma to have gcc/Xcode suppress specific warnings, similar to Java's @SuppressWarning annotation? I compile with -Wall as a rule, but there are some situations where I'd like to just ignore a specific warning (e.g. while writing some quick/dirty code just to help debug something). I'm not looking for "fix the code" answer...

C: warns about implicit long to int conversion

Hi, I was wondering whether there is a way to tell the compiler (I'm on gcc version 4.1.2 20080704 (Red Hat 4.1.2-46) or icc 11.1) to throw a warning whenever a long-to-int implicit conversion takes place. For example, compiling the file test.c which contains the code: #include <stdio.h> #include <stdlib.h> int main(int argc, char** a...

How to suppress GCC warnings from library headers?

I have a project that uses log4cxx, boost, etc. libraries whose headers generate lots of (repetitive) warnings. Is there a way to suppress warnings from library includes (i.e. #include <some-header.h>) or includes from certain paths? I'd like to use -Wall and/or -Wextra as usual on project code without relevant info being obscured. I cur...

Why assignment of double to int does not trigger gcc warnings?

int i = 3.1 / 2 does not cause any warnings,even with -Wall option.Sometimes,I would like to know where precision lose.Why gcc does not support this warning,while msvc support this one? thanks. EDIT: my gcc -v shows Configured with: ../../gcc-4.4.1/configure --prefix=/mingw --build=mingw32 --enable-languages=c,ada,c++,fortran,objc,o...

C/GCC Warnings - Write once and test everywhere?

I'm writing a command line program in ANSI C to parse a Quake 2 map file to report how many entities and textures are being used. My development machine is MacBook. I'm testing on OS X Snow Leopard (32-bit), Windows XP (32-bit) and Vista (64-bit), and Ubuntu 9.10 (32-bit). The code is flawless on the OS X and GCC 4.2. The other pla...

Porting C source code written for 32 to 64 bit

The C source codes that I am trying to port into 64 bit runs without any warning in the 32 bit environment. When I compile in 64 bit linux environment with the compile gcc (Ubuntu 4.4.1-4ubuntu9) 4.4.1, it shows the following warning mostly: warning: cast to pointer from integer of different size The above warning were the most. I us...

C warning implicit declaration of function 'exit'

This is my warning. implicit declaration of function 'exit' How i can remove it. i am using linux & gcc compiler. ...