From owner-freebsd-hackers Wed May 21 12:21:06 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id MAA29856 for hackers-outgoing; Wed, 21 May 1997 12:21:06 -0700 (PDT) Received: from awfulhak.demon.co.uk (awfulhak.demon.co.uk [158.152.17.1]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id MAA29827 for ; Wed, 21 May 1997 12:20:40 -0700 (PDT) Received: from awfulhak.demon.co.uk (localhost [127.0.0.1]) by awfulhak.demon.co.uk (8.8.5/8.8.5) with ESMTP id UAA18664; Wed, 21 May 1997 20:14:47 +0100 (BST) Message-Id: <199705211914.UAA18664@awfulhak.demon.co.uk> X-Mailer: exmh version 1.6.9 8/22/96 To: Michael Smith cc: jgrosch@superior.mooseriver.com, hackers@FreeBSD.ORG Subject: Re: Porting question In-reply-to: Your message of "Wed, 21 May 1997 15:33:07 +0930." <199705210603.PAA09769@genesis.atrad.adelaide.edu.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Wed, 21 May 1997 20:14:47 +0100 From: Brian Somers Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > 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 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 , Don't _EVER_ lose your sense of humour....