misc/56206: src/sys/sys/cdefs.h uses PreProcessor variablesthat
aren't defined, causing noisy warnings.
Bruce Evans
bde at zeta.org.au
Sun Aug 31 00:40:17 PDT 2003
The following reply was made to PR misc/56206; it has been noted by GNATS.
From: Bruce Evans <bde at zeta.org.au>
To: Garrett Wollman <wollman at khavrinen.lcs.mit.edu>
Cc: freebsd-gnats-submit at freebsd.org
Subject: Re: misc/56206: src/sys/sys/cdefs.h uses PreProcessor variables that
aren't defined, causing noisy warnings.
Date: Sun, 31 Aug 2003 17:33:09 +1000 (EST)
On Sat, 30 Aug 2003, Garrett Wollman wrote:
> <<On Sat, 30 Aug 2003 14:19:14 -0500 (CDT), Larry Rosenman <ler at lerctr.org> said:
>
> > The following patch shuts it up, and is functionally equivalent.
>
> Actually, the patch is not functionally equivalent:
>
> > -#if __STDC_VERSION__ < 199901
> > +#if defined(__STDC_VERSION__) && __STDC_VERSION__ < 199901
>
> 0 < 199901
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901
would be functionally equivalent, but is intentionally not used because
it is harder to read.
The feature of undefined identifiers being 0 in cpp expressions is used
a lot in FreeBSD headers. E.g., in <sys/cdefs.h>:
#if __GNUC__ < 2 || __GNUC__ == 2 && __GNUC_MINOR__ < 5
When __GNUC__ is not defined, it evaluates as 0 so this expression is
true (0 < 2). There is no warning about this from gcc because gcc
always defines __GNUC__, at least in the broken versions that warn
about this. Compilers that aren't gcc shouldn't define __GNUC__ or
have the bug.
The bug may be in FreeBSD's version of gcc. gcc normally suppresses
warnings in "system" headers but FreeBSD turns this off since it wants
to check for errors in system headers and at least old versions of gcc
don't understand which headers are system ones anyway (for buildworld,
the system headers aren't under /usr/include).
Bruce
More information about the freebsd-bugs
mailing list