Date: Wed, 21 May 1997 10:57:20 -0400 (EDT) From: Chuck Robey <chuckr@glue.umd.edu> To: Josef Grosch <jgrosch@superior.mooseriver.com> Cc: hackers@FreeBSD.ORG Subject: Re: Porting question Message-ID: <Pine.OSF.3.95q.970521104626.15083A-100000@skipper.eng.umd.edu> In-Reply-To: <199705210519.WAA08921@superior.mooseriver.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <sys/param.h> #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! ----------------------------+-----------------------------------------------
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.OSF.3.95q.970521104626.15083A-100000>