Date: Sun, 31 Aug 2003 00:40:15 -0700 (PDT) From: Bruce Evans <bde@zeta.org.au> To: freebsd-bugs@FreeBSD.org Subject: Re: misc/56206: src/sys/sys/cdefs.h uses PreProcessor variablesthat aren't defined, causing noisy warnings. Message-ID: <200308310740.h7V7eFnh014813@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR misc/56206; it has been noted by GNATS. From: Bruce Evans <bde@zeta.org.au> To: Garrett Wollman <wollman@khavrinen.lcs.mit.edu> Cc: freebsd-gnats-submit@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@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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200308310740.h7V7eFnh014813>