Paolo Bonzini wrote:
> You can put "#pragma GCC system_header" in the gnulib files.

However, this pragma not only affects warnings, it also causes __STDC__ to
evaluate to 0 in such a file, on some platforms (those which define
STDC_0_IN_SYSTEM_HEADERS, namely Solaris and Interix).

Incidentally, the same also happens with -isystem. (See the attached log
of an experiment done on Solaris.)

Since -isystem is some burden on the gnulib user (not a big one, but anyway)
I propose to add
   #ifdef __GNUC__
   # pragma GCC system_header
   #endif
to all gnulib headers that use @[EMAIL PROTECTED] Fortunately gnulib does not
use __STDC__ in any of these header files any more.

Bruno

=====================================================================
$ mkdir dir1

$ mkdir dir2

$ cat > foo.c
#include "foo.h"

$ cat > dir1/foo.h
in dir1: __STDC__
#include_next "foo.h"

$ cat  > dir2/foo.h
in dir2: __STDC__

$ gcc -Idir1 -Idir2 -E foo.c                                       
# 1 "foo.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "foo.c"
# 1 "dir1/foo.h" 1
in dir1: 1
# 1 "dir2/foo.h" 1
in dir2: 1
# 3 "dir1/foo.h" 2
# 2 "foo.c" 2

$ gcc -Idir1 -isystem dir2 -E foo.c
# 1 "foo.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "foo.c"
# 1 "dir1/foo.h" 1
in dir1: 1
# 1 "dir2/foo.h" 1 3 4
in dir2: 0
# 3 "dir1/foo.h" 2
# 2 "foo.c" 2

$ gcc -isystem dir1 -isystem dir2 -E foo.c
# 1 "foo.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "foo.c"
# 1 "dir1/foo.h" 1 3 4
in dir1: 0
# 1 "dir2/foo.h" 1 3 4
in dir2: 0
# 3 "dir1/foo.h" 2 3 4
# 2 "foo.c" 2

$ cat > dir1/foo.h 
#pragma GCC system_header
in dir1: __STDC__
#include_next "foo.h"

$ gcc -Idir1 -Idir2 -E foo.c              
# 1 "foo.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "foo.c"
# 1 "dir1/foo.h" 1
# 2 "dir1/foo.h" 3
in dir1: 0
# 1 "dir2/foo.h" 1 3
in dir2: 0
# 4 "dir1/foo.h" 2 3
# 2 "foo.c" 2




Reply via email to