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
          Reporter: glisse at gcc dot
  Target Milestone: ---

#define foo bar

#include <a.h>
int main(){

$ 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’
 #define foo bar
x.c:4:3: note: in expansion of macro ‘foo’

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.

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?

Reply via email to