From ler@lerlaptop.lerctr.org  Sat Aug 30 12:19:18 2003
Return-Path: <ler@lerlaptop.lerctr.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 157BB16A4BF
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 30 Aug 2003 12:19:18 -0700 (PDT)
Received: from lerlaptop.lerctr.org (lerlaptop.lerctr.org [207.158.72.14])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 118AF43FBD
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 30 Aug 2003 12:19:15 -0700 (PDT)
	(envelope-from ler@lerlaptop.lerctr.org)
Received: from lerlaptop.lerctr.org (localhost [127.0.0.1])
	by lerlaptop.lerctr.org (8.12.9/8.12.9) with ESMTP id h7UJJEK9003611
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 30 Aug 2003 14:19:14 -0500 (CDT)
	(envelope-from ler@lerlaptop.lerctr.org)
Received: (from ler@localhost)
	by lerlaptop.lerctr.org (8.12.9/8.12.9/Submit) id h7UJJElh003555;
	Sat, 30 Aug 2003 14:19:14 -0500 (CDT)
Message-Id: <200308301919.h7UJJElh003555@lerlaptop.lerctr.org>
Date: Sat, 30 Aug 2003 14:19:14 -0500 (CDT)
From: Larry Rosenman <ler@lerctr.org>
Reply-To: Larry Rosenman <ler@lerctr.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: src/sys/sys/cdefs.h uses PreProcessor variables that aren't defined, causing noisy warnings.
X-Send-Pr-Version: 3.113
X-GNATS-Notify: ler@lerctr.org

>Number:         56206
>Category:       misc
>Synopsis:       src/sys/sys/cdefs.h uses PreProcessor variables that aren't defined, causing noisy warnings.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sat Aug 30 12:20:14 PDT 2003
>Closed-Date:    Thu Jul 01 03:14:26 GMT 2004
>Last-Modified:  Thu Jul 01 03:14:26 GMT 2004
>Originator:     Larry Rosenman
>Release:        FreeBSD 5.1-CURRENT i386
>Organization:
LERCTR Consulting
>Environment:
System: FreeBSD lerlaptop.lerctr.org 5.1-CURRENT FreeBSD 5.1-CURRENT #42: Fri Aug 29 19:27:56 CDT 2003 ler@lerlaptop.lerctr.org:/usr/obj/usr/src/sys/LERLAPTOP i386


	
>Description:
the /usr/include/sys/cdefs.h file uses __STD_C__ and _POSIX_C_SOURCE variables
without them being defined.  This causes noise that is unneeded. 

The following patch shuts it up, and is functionally equivalent. 

Can we get this applied? 
>How-To-Repeat:
compile KDE and see all the warnings. 
>Fix:

--- /usr/src/sys/sys/cdefs.h.orig	Sun Jul 27 08:03:46 2003
+++ /usr/src/sys/sys/cdefs.h	Sat Aug 30 14:11:09 2003
@@ -171,7 +171,7 @@
  * software that is unaware of C99 keywords.
  */
 #if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95)
-#if __STDC_VERSION__ < 199901
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ < 199901
 #define	__restrict
 #else
 #define	__restrict	restrict
@@ -323,13 +323,13 @@
  */
 
 /* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */
-#if _POSIX_C_SOURCE == 1
+#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1
 #undef _POSIX_C_SOURCE		/* Probably illegal, but beyond caring now. */
 #define	_POSIX_C_SOURCE		199009
 #endif
 
 /* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */
-#if _POSIX_C_SOURCE == 2
+#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2
 #undef _POSIX_C_SOURCE
 #define	_POSIX_C_SOURCE		199209
 #endif

>Release-Note:
>Audit-Trail:

From: Larry Rosenman <ler@lerctr.org>
To: FreeBSD-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: misc/56206: src/sys/sys/cdefs.h uses PreProcessor variables
 that aren't defined, causing noisy warnings.
Date: Sat, 30 Aug 2003 14:34:48 -0500

 my patch apparently isn't as equivalent as I thought. :-(
 
 The openldap22-server port didn't like it.
 
 Is there some way to quiet the warnings AND be compatible?
 
 LER
 
 -- 
 Larry Rosenman                     http://www.lerctr.org/~ler
 Phone: +1 972-414-9812                 E-Mail: ler@lerctr.org
 US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749
 

From: Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
To: Larry Rosenman <ler@lerctr.org>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: misc/56206: src/sys/sys/cdefs.h uses PreProcessor variables that
	aren't defined, causing noisy warnings.
Date: Sat, 30 Aug 2003 16:05:27 -0400 (EDT)

 <<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
 
 -GAWollman
 

From: Larry Rosenman <ler@lerctr.org>
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: Sat, 30 Aug 2003 15:09:35 -0500

 --On Saturday, August 30, 2003 16:05:27 -0400 Garrett Wollman 
 <wollman@khavrinen.lcs.mit.edu> 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
 and doesn't the #if __STDC_VERSION__ < 199901 have the same effect, except 
 when
 __STDC_VERSION__ is NOT defined?  which is what the compiler was whining 
 about?
 
 
 >
 > -GAWollman
 
 
 
 -- 
 Larry Rosenman                     http://www.lerctr.org/~ler
 Phone: +1 972-414-9812                 E-Mail: ler@lerctr.org
 US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749
 

From: Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
To: Larry Rosenman <ler@lerctr.org>
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: Sat, 30 Aug 2003 16:26:52 -0400 (EDT)

 >>> -#if __STDC_VERSION__ < 199901
 >>> +#if defined(__STDC_VERSION__) && __STDC_VERSION__ < 199901
 >> 
 >> 0 < 199901
 > and doesn't the #if __STDC_VERSION__ < 199901 have the same effect, except 
 
 Let me try to spell this out.
 
 When __STDC_VERSION__ is not defined, the preprocessor expression
 `__STDC_VERSION < 199901' evaluates, by definition, to true, because
 0L < 199901L (which is why I consider this GCC warning to be bogus).
 
 When __STDC_VERSION__ is not defined, the preprocessor expression
 `defined(__STDC_VERSION__) && __STDC_VERSION__ < 199901' evaluates to
 false, because __STDC_VERSION__ is not defined.
 
 -GAWollman
 

From: Larry Rosenman <ler@lerctr.org>
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: Sat, 30 Aug 2003 15:33:56 -0500

 --On Saturday, August 30, 2003 16:26:52 -0400 Garrett Wollman 
 <wollman@khavrinen.lcs.mit.edu> wrote:
 
 >
 >>>> -#if __STDC_VERSION__ < 199901
 >>>> +#if defined(__STDC_VERSION__) && __STDC_VERSION__ < 199901
 >>>
 >>> 0 < 199901
 >> and doesn't the #if __STDC_VERSION__ < 199901 have the same effect,
 >> except
 >
 > Let me try to spell this out.
 >
 > When __STDC_VERSION__ is not defined, the preprocessor expression
 > `__STDC_VERSION < 199901' evaluates, by definition, to true, because
 > 0L < 199901L (which is why I consider this GCC warning to be bogus).
 >
 > When __STDC_VERSION__ is not defined, the preprocessor expression
 > `defined(__STDC_VERSION__) && __STDC_VERSION__ < 199901' evaluates to
 > false, because __STDC_VERSION__ is not defined.
 aha.  I think I agree with you on the Warning.
 
 Thanks for the explanation.
 
 LER
 
 
 
 
 -- 
 Larry Rosenman                     http://www.lerctr.org/~ler
 Phone: +1 972-414-9812                 E-Mail: ler@lerctr.org
 US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749
 

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
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Thu Jul 1 03:13:38 GMT 2004 
State-Changed-Why:  
The discussion that ensued in the responses to this PR seem to indicate 
that the current behavior is intentional, so this can not be considered 
a bug. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=56206 
>Unformatted:
