Compiling C and C++ code with the highest warning levels is a good practice and helps spotting potential errors. For GCC the flags
-Wall -Wextra
will generate a lot of useful warning messages about unused parameters etc.
Unfortunately, this is not the common practice and often the own compiler settings concerning the warning level results in dozens of warnings from system headers on which the own code relies, making it impossible to spot warnings from your own code in the endless mass of console output.
Fortunately, GCC has a way to ignore warnings from foreign headers. Instead of using -I
to specify an include path, -isystem
tells the compiler to treat the includes from the given path as system headers where no warnings should be reported.
If CMake is used to create the Makefile, a special argument to the INCLUDE_DIRECTORIES
function generates these compiler flags:
INCLUDE_DIRECTORIES(SYSTEM /usr/include /and/other /system/paths)