From owner-freebsd-hackers Wed May 21 07:57:29 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id HAA14507 for hackers-outgoing; Wed, 21 May 1997 07:57:29 -0700 (PDT) Received: from po2.glue.umd.edu (root@po2.glue.umd.edu [129.2.128.45]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id HAA14502 for ; Wed, 21 May 1997 07:57:25 -0700 (PDT) Received: from skipper.eng.umd.edu (skipper.eng.umd.edu [129.2.103.24]) by po2.glue.umd.edu (8.8.5/8.8.5) with ESMTP id KAA28177; Wed, 21 May 1997 10:57:22 -0400 (EDT) Received: from localhost (chuckr@localhost) by skipper.eng.umd.edu (8.8.5/8.6.4) with SMTP id KAA14240; Wed, 21 May 1997 10:57:21 -0400 (EDT) X-Authentication-Warning: skipper.eng.umd.edu: chuckr owned process doing -bs Date: Wed, 21 May 1997 10:57:20 -0400 (EDT) From: Chuck Robey X-Sender: chuckr@skipper.eng.umd.edu To: Josef Grosch cc: hackers@FreeBSD.ORG Subject: Re: Porting question In-Reply-To: <199705210519.WAA08921@superior.mooseriver.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk On Tue, 20 May 1997, Josef Grosch wrote: > 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. This question has been the subject (occaisonally) of some debate. I'll give you my own opinion, FWIW. In the makefile, put .if exists(sys/param.h) CFLAGS+=-DHAVE_PARAM_H .endif At the top of the source file, put #ifdef HAVE_PARAM_H #include #endif And around anything that has to be changed, like the sys_errlist stuff: #ifdef BSD4_4 /* defined in sys/param.h */ extern __const char *__const sys_errlist[]; #else extern char* sys_errlist[]; #endif This works unless the user is on a SYSV make, where they don't have the #if exists construct in their make utility, so maybe a comment for the sysv people would be in order. I've never seen a method that works equally well for SYSV make as well as the far smarter bsd and GNU makes. If you make it work for the dumb sysv make, then other users have to patch in a -DHAVE_PARAM_H manually. ----------------------------+----------------------------------------------- Chuck Robey | Interests include any kind of voice or data chuckr@eng.umd.edu | communications topic, C programming, and Unix. 9120 Edmonston Ct #302 | Greenbelt, MD 20770 | I run Journey2 and picnic, both FreeBSD (301) 220-2114 | version 3.0 current -- and great FUN! ----------------------------+-----------------------------------------------