https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91187
Bug ID: 91187 Summary: Is it possible to make -Wzero-as-null-pointer-constant learn about extern "C"? Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: aacid at kde dot org Target Milestone: --- This is more a wish than a bug report, sorry if this is not the proper place to talk about this. It also contains two scenarios that for my "i know nothing about compilers" seem to be the same thing, but if you prefer me to close this and file two different issues i'm happy to also do that :) I like to have -Wzero-as-null-pointer-constant enabled, but when interfacing with C libraries it's painful because it says "you're using a 0 when you should use nullptr", but in some cases "you can't". Scenario 1: #### main.cpp #### extern "C" { #include "myzlib.h" } int main(int argc, char **argv) { void *bla = Z_NULL; } #### myzlib.h #### #define Z_NULL 0 I guess you could argue here that one could stop using Z_NULL and use nullptr directly but given that Z_NULL is what the documentation says to use, it would be cool if one could see that Z_NULL is defined as 0 inside an include wrapped by extern "C" and not give a warning Scenario 2: #### main.cpp #### extern "C" { #include "clib.h" } int main(int argc, char **argv) { simple(3); } #### clib.h #### typedef struct { int value; int *something; } MyStruct; #define simple(x) MyStruct s; s.value = x; s.something = 0; In this case the use of 0 as nullptr is totally inside the extern "C" header, so there's nothing one can do to not have a warning.