c++gccincludegcc-pedantic

scope g++ pedantic compile


Is it possible to restict the -pedantic switch for certain files? For example I compile stuff using alsa-lib, which I refer with standard

#include <alsa/asoundlib.h>

however -pedantic panics on this file. I am willing and interested in correcting warning and oddities in my own code, but not in alsa and other unrelated third parties.

Is there a way to scope the -pedantic usage?


Solution

  • Normally, GCC suppresses warnings in system headers, unless you explicitly specify -Wsystem-headers. And normally, files included with <> from /usr/include are treated as system headers. Your question suggests you specifically added something that makes GCC not treat it as a system header. You haven't specified which compiler options you're using, but are you adding any pointless -I* options that might make /usr/include get treated as a non-system header directory?

    If all else fails, you can use the -isystem to actually add directories as system header directories, but you shouldn't need that here.

    Edit: after re-reading the question, if you installed alsa-lib in a non-standard path, then my remark that you should not need the -isystem option may be wrong: it may be exactly what you need.