Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 8 Aug 1998 21:49:23 -0400 (EDT)
From:      Thomas David Rivers <rivers@dignus.com>
To:        jdp@polstra.com, rivers@dignus.com
Cc:        hackers@FreeBSD.ORG
Subject:   Re: C and static initialization with unions
Message-ID:  <199808090149.VAA28991@lakes.dignus.com>
In-Reply-To: <199808082104.OAA20050@austin.polstra.com>

next in thread | previous in thread | raw e-mail | index | archive | help
> 
> > Let me add to this discussion my (now somewhat tired) song regarding
> > compiling older pre-ANSI software.
> >
> > It's very nice that we can 'turn off' "const", "volatile",
> > prototypes in the header files; just for this purpose...
> >
> > Every now-and-then, a stray "const" seems to slip into the headers;
> > which breaks some of my older software...
> 
> How could that happen?  We don't change your old software.  We change
> FreeBSD.  FreeBSD is built using the FreeBSD compiler.  That compiler
> is not K&R, and it never will be K&R again.  If you are using an old
> compiler to compile FreeBSD header files, then I can only say, "Don't
> do that."  We have explicitly abandoned the goal of being compatible
> with K&R compilers.

 I believe you can find more details in the mail archives...  I've
 sent out mail on it in the past.

> 
> If you mean that your old software isn't const-correct, then (a)
> that's a compiler warning under FreeBSD, not an error, and (b) isn't
> it about time you fixed your software?  The ANSI/ISO C standard was
> ratified almost 10 years ago.  Surely everybody has had ample time to
> get used to the idea by now.


 Actually, the problem I have is with new software...    The situation
 is that I have a set of portable C code which has to be compiled
 with a non-ANSI compiler.  Now, you're right that I shouldn't have
 to contend with a non-ANSI compiler in this day and age, but here's
 the reasons I do:

	1) Typically, the ANSI compiler is an add-on cost, using the
	   "free" non-ANSI compiler can save money.

	2) On at least one machine, the ANSI compiler has soooo many bugs
	   as to make it unusable.


 So, in order to ferret out potential problems *before* I try to compile
 on those platforms where I don't have gcc, and have to use the non-ANSI
 compiler; I use -traditional on FreeBSD.

 Every now-and-then, a stray 'const' will appear in the freebsd system
 headers; which breaks the -traditional compilation.  It's kinda 
 bothersome, especially since <sys/cdefs.h> defines a nice symbol
 to handle this (__const).

 For example, in 2.2.6; resolve.h has:

resolv.h:extern const struct res_sym __p_class_syms[];
resolv.h:extern const struct res_sym __p_type_syms[];
resolv.h:const char *   sym_ntos __P((const struct res_sym *, int, int *));
resolv.h:const char *   sym_ntop __P((const struct res_sym *, int, int *));
resolv.h:const char *   loc_ntoa __P((const u_char *, char *));
resolv.h:const char *   hostalias __P((const char *));
resolv.h:const char *   p_class __P((int));
resolv.h:const char *   p_time __P((u_int32_t));
resolv.h:const char *   p_type __P((int));
 ...
 though it explicitly #includes <sys/cdefs.h>

 The one I typically run into is <time.h>: 


time.h:const char *strptime __P((const char *, const char *, struct tm *));

 so normally the first thing I do after an installation of a new FreeBSD 
is fix time.h  [I believe there already is a PR# of this particular problem.]


 My point is; it sure is nice for the -traditional option to actually
work... and every now-and-then, you have a reasonable reason for wanting
it to.  

	- Dave Rivers -

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199808090149.VAA28991>