standards/116346: FreeBSD has no conforming C implementation

Erik Trulsson ertr1013 at student.uu.se
Fri Sep 14 08:00:11 PDT 2007


The following reply was made to PR standards/116346; it has been noted by GNATS.

From: Erik Trulsson <ertr1013 at student.uu.se>
To: Rhialto <rhialto at falu.nl>
Cc: freebsd-gnats-submit at FreeBSD.org
Subject: Re: standards/116346: FreeBSD has no conforming C implementation
Date: Fri, 14 Sep 2007 16:53:45 +0200

 On Fri, Sep 14, 2007 at 03:35:06PM +0200, Rhialto wrote:
 > On Fri 14 Sep 2007 at 14:44:50 +0200, Erik Trulsson wrote:
 > > Yes, it does.  You do however have to invoke the C compiler in
 > > standard-conforming mode.
 > > By default gcc (like most C compilers) is not in standards-conforming mode.
 > > 
 > > Try invoking it as 'gcc -ansi' or 'c89' to get a C compiler conforming to
 > > the 1989 ANSI C standard.  (Invoking it as 'c99' or as 'gcc -std=c99' should
 > > get a C99 compiler, although I believe support for the 1999 C standard is
 > > not quite complete.)
 >  
 > Of course no makefile project ever does that at all, in practice, yet
 > they still expect to have the promised namespace available for their own
 >  identifiers.
 
 They should not expect that.
 
 >  
 > I was made aware of this problem when some project was using the "unix"
 > preprocessor definition as a feature test, and it failed to build on a
 > different BSD system, which IMHO is more correct in this regard.
 
 You mean the "correct" system is the one where this program did *not*
 compile?  Perhaps correct, but not terribly useful IMNSHO.
 
 
 >  
 > I don't know where to look this up in POSIX and related standards, but I
 > don't expect that any of them actually *requires* a pre-#defined unix,
 > since they most likely don't want to contradict the C standard. If they
 > would mention any such feature test at all, they would require
 > #inclusion of some specific header first, or use a name which is
 > reserved to the implementation, such as __unix__.
 >  
 > Otherwise, by your reasoning, the default-invoked compiler could do
 > anything, and you would not need to bother having all those __-prefixed
 > names in /usr/include/sys/*.
 
 No relevant standard say anything at all about what should happen or not
 happen if you invoke a C compiler in non-conforming mode.
 
 >  
 > Therefore, there is no standards-related reason for having "unix" and I
 > still argue for removing it.
 
 As far as I know no standard requires "unix" to be predefined.  The reason
 it exists is presumably for compatibility with older programs and older
 compilers that did use it.  For programs that require a standard-conforming
 compiler you can invoke the C compiler as described above.
 
 The fact that GCC by default is in non-standard comforming mode should come
 as a surprise to nobody.  That has after all been the case for the last two
 decades and is quite well documented by now.  
 
 
 It is worth noting that I as far as I can tell there is also no standard
 that requires 'cc' by itself to invoke a fully standard-compliant C
 compiler -- which C dialect it will compile is not specified.
 If you need a C compiler that is standard compliant you should use 'c89'
 (which has apparently been replaced by 'c99' in the latest POSIX standard.)
 
 
 As far as I can tell FreeBSD *does* have a conforming C compiler, and *is*
 complying with the relevant standards in this aspect.
 
 
 
 -- 
 <Insert your favourite quote here.>
 Erik Trulsson
 ertr1013 at student.uu.se


More information about the freebsd-standards mailing list