bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using gnulib with -pedantic, I get many warnings about #include_next


From: Bruno Haible
Subject: Re: Using gnulib with -pedantic, I get many warnings about #include_next
Date: Mon, 25 Aug 2008 12:11:02 +0200
User-agent: KMail/1.5.4

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 @address@hidden 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

[Prev in Thread] Current Thread [Next in Thread]