11

I am familiar with warning suppressing pragmas for GCC and Keil (they are different, but the usage is pretty much the same). For a third-party headers I can do something like this:

#pragma push
#pragma suppress warning
#include "whatever.h"
#pragma pop

But how can I suppress warnings from third-party sources? Both Eclipse+GCC and Keil generate them. The only solution I came up is making whapper .c-file, which will include other .c files, which seems to be very dirty trick.

Are there any other solutions?

renick
  • 3,873
  • 2
  • 31
  • 40
Amomum
  • 6,217
  • 8
  • 34
  • 62
  • 1
    If you'd have one well-named & set-apart further empty source file including the third party one, I'd call this a "trick", and not a "very dirty trick". Matter of taste of course :-) I do agree that a more 'standard' solution is highly preferable. – meaning-matters Aug 30 '13 at 10:20
  • These trick will be also a bit inconvenient for Eclipse, coz eclipse by default includes all files in project folder in the build process. So this third-party sources will be built twice - one as themselves and another one as included. Of course, they can be manually excluded from built, but that's another pain. – Amomum Aug 30 '13 at 10:25

2 Answers2

4

with gcc , while compiling you can use -w option to suppress warnings.

-w : Inhibit all warning messages.

Example:

gcc -w third_party_sourcefile.c 
Gangadhar
  • 10,248
  • 3
  • 31
  • 50
  • 1
    That's a good way, but I'm not sure it will be suitable for Eclipse, since it generates makefiles. – Amomum Aug 30 '13 at 11:07
  • @Amomum ,Sorry i am not familiar with Eclipse. some one will definitely give you useful info regarding Eclipse also. – Gangadhar Aug 30 '13 at 11:12
2

You may want to use -isystem instead of -Idir third party headers. See GCC manual.

If you're ok to edit third party source files, you can use #pragma GCC diagnostic ignored "-Wwarning-to-disable" see GCC manual.

Gregory Pakosz
  • 69,011
  • 20
  • 139
  • 164
  • Headers are out of question. Also, I'm not sure, how can I do this with Eclipse (since I use it's interface for pointing include directories). – Amomum Aug 30 '13 at 10:45