From owner-freebsd-stable@FreeBSD.ORG Sun Aug 31 12:36:59 2003 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1412516A4BF for ; Sun, 31 Aug 2003 12:36:59 -0700 (PDT) Received: from falcon.midgard.homeip.net (h76n3fls20o913.bredband.comhem.se [213.67.148.76]) by mx1.FreeBSD.org (Postfix) with SMTP id 632F543FE5 for ; Sun, 31 Aug 2003 12:36:56 -0700 (PDT) (envelope-from ertr1013@student.uu.se) Received: (qmail 17777 invoked by uid 1001); 31 Aug 2003 19:36:53 -0000 Date: Sun, 31 Aug 2003 21:36:53 +0200 From: Erik Trulsson To: "M. Warner Losh" Message-ID: <20030831193653.GA45277@falcon.midgard.homeip.net> Mail-Followup-To: "M. Warner Losh" , wollman@khavrinen.lcs.mit.edu, stable@freebsd.org References: <20030830161813.GA28890@twisted.net> <200308301649.h7UGnF5H042361@khavrinen.lcs.mit.edu> <20030830171343.GA33800@falcon.midgard.homeip.net> <20030831.113543.12223209.imp@bsdimp.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030831.113543.12223209.imp@bsdimp.com> User-Agent: Mutt/1.5.4i cc: stable@freebsd.org cc: wollman@khavrinen.lcs.mit.edu Subject: Re: POSIX_C_SOURCE X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Aug 2003 19:36:59 -0000 On Sun, Aug 31, 2003 at 11:35:43AM -0600, M. Warner Losh wrote: > In message: <20030830171343.GA33800@falcon.midgard.homeip.net> > Erik Trulsson writes: > : /* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */ > : #if _POSIX_C_SOURCE == 1 > : #undef _POSIX_C_SOURCE /* Probably illegal, but beyond caring now. */ > : @@ -280,6 +282,8 @@ > : #undef _POSIX_C_SOURCE > : #define _POSIX_C_SOURCE 199209 > : #endif > > That's 100% legal and should *NOT* produce a warning. Garrett is > right. It is 100% legal, yes. Nobody has said differently. I disagree that it should not produce a warning[1], but it *does* *not* *matter* whether a warning should or should not be produced. Gcc *does* give a warning on that code, and those warnings can be quite annoying. Applying the patch I posted will stop gcc from issuing the annoying warnings and has no other effects. It might not be the "correct" way of fixing the problem (the problem being that gcc issues lots of annoying and useless warnings on the code in cdefs.h when compiling perfectly fine programs) but I haven't seen anybody propose any other solution that is "better". Is there some *actual* problem with the patch I posted which would prevent it from being applied to RELENG_4 ? (Other than the objection of "it shouldn't be neccessary, gcc shouldn't give a warning on that code" which is irrelevant since gcc does issue a warning.) The patch is: a) Perfectly legal C b) Has no harmful sideeffects c) Solves a problem (getting rid of annoying, useless, warnings) d) Is arguably better style than the previous code (this is most certainly arguable, since we are essentially arguing about it right now, but since several different, reasonable, opinions obviously exist it is a fairly good indication that there is no "right" way to do this and my points a)-c) above should be given more weight than what somebody thinks the "right" programming style is. There are three other possible "solutions", each of which I consider to be much worse: a) Do nothing. Accept that gcc will spew out lots of annoying, useless warnings when compiling several ports. b) Change the compiler flags used by all the affected ports, so that they don't have the warning enabled. (I.e. remove -Wundef from the flags used by the affected ports.) c) Change the documented behaviour of gcc so it doesn't issue a warning for this case. Of these b) is the only option that I would consider to be somewhat acceptable and that would probably entail a lot of work. [1] I think that relying on the fact that undefined preprocessor constants is replaced by the value 0 in preprocessor expressions, although legal, is lousy programming practice and should be discouraged. Gcc certainly should issue that warning when invoked with -Wundef since that is what that option is documented to do. -- Erik Trulsson ertr1013@student.uu.se