Date: Wed, 21 May 1997 20:14:47 +0100 From: Brian Somers <brian@awfulhak.org> To: Michael Smith <msmith@atrad.adelaide.edu.au> Cc: jgrosch@superior.mooseriver.com, hackers@FreeBSD.ORG Subject: Re: Porting question Message-ID: <199705211914.UAA18664@awfulhak.demon.co.uk> In-Reply-To: Your message of "Wed, 21 May 1997 15:33:07 %2B0930." <199705210603.PAA09769@genesis.atrad.adelaide.edu.au>
next in thread | previous in thread | raw e-mail | index | archive | help
> Josef Grosch stands accused of saying: > > I know this issue has been beat to death several times before BUT..... > > > > I am porting a piece of code to FreeBSD and gcc bitches about this; > > > > extern char* sys_errlist[]; > > > > Now the fast way to handle this is; > > > > #ifndef __FreeBSD__ > > extern char* sys_errlist[]; > > #endif > > > > But this is very non-portable. Any suggestions as the correct way to > > handle this would be helpful. > > Traditional is > > #ifndef HAVE_SYS_ERRLIST > extern char* sys_errlist[]; > #endif > > or, if you can guarantee that <sys/param.h> has been included, you can > test the BSD macro. Hmm, of course you mean extern const char * const sys_errlist[]. If this prototype is used, it doesn't matter if you've included stdio. If it conflicts with anything, that something is broken - a poor reason for breaking your own code IMO. Maybe gcc should allow the "strengthening" of a prototype - so saying extern char *sys_errlist[]; extern const char *sys_errlist[]; extern const char * const sys_errlist[]; is ok (probably warned about under -pedantic or with its own -W), but extern const char *sys_errlist[]; extern char *sys_errlist[]; is an error. That way, people can successfully "overload" include files with others that say "#include "/usr/include/..." (there's a #include_next or something somewhere in gcc too isn't there) and then "fix" things like this (rather than having to #define them away before #including the file). Look at it like defaulting arguments in C++ - you can get stricter everytime you prototype a function. > > Josef Grosch | Another day closer to a | FreeBSD 2.2.1 > > -- > ]] Mike Smith, Software Engineer msmith@gsoft.com.au [[ > ]] Genesis Software genesis@gsoft.com.au [[ > ]] High-speed data acquisition and (GSM mobile) 0411-222-496 [[ > ]] realtime instrument control. (ph) +61-8-8267-3493 [[ > ]] Unix hardware collector. "Where are your PEZ?" The Tick [[ -- Brian <brian@awfulhak.org>, <brian@freebsd.org> <http://www.awfulhak.org> Don't _EVER_ lose your sense of humour....
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199705211914.UAA18664>