https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78000
Bug ID: 78000 Summary: -Wimplicit-function-declaration inhibited with macro from system headers Product: gcc Version: 7.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: glisse at gcc dot gnu.org Target Milestone: --- i/a.h: #define foo bar x.c: #include <a.h> int main(){ foo(42); } $ gcc x.c -isystem i -c $ gcc x.c -I i -c In file included from x.c:1:0: x.c: In function ‘main’: i/a.h:1:13: warning: implicit declaration of function ‘bar’ [-Wimplicit-function-declaration] #define foo bar ^ x.c:4:3: note: in expansion of macro ‘foo’ foo(42); ^~~ This problem occurs for instance with GMP headers (installed by the distribution in /usr/include) that have #define mpf_out_str __gmpf_out_str but only declare the function if stdio.h was included first. Users don't get any indication that they are using an undeclared function. http://stackoverflow.com/q/40069876/1918193 At least in this case, it seems that it would be better to use the location of 'foo(42)' to determine if the issue is in a system header or not. Are there cases where the current behavior is preferred?