Date: Mon, 4 Mar 2002 08:06:08 -0500 From: Brian T.Schellenberger <bts@babbleon.org> To: Aleksander Rozman - Andy <andy@kksonline.com>, freebsd-hackers@FreeBSD.ORG Cc: freebsd-questions@FreeBSD.ORG Subject: Re: How to write code in FreeBSD Message-ID: <20020304130608.9A2CDBA03@i8k.babbleon.org> References: <5.0.2.1.0.20020302125303.02c1ca90@164.8.8.5>
next in thread | previous in thread | raw e-mail | index | archive | help
On Saturday 02 March 2002 09:41 am, Brian T. Schellenberger wrote: > On Saturday 02 March 2002 06:57 am, Aleksander Rozman - Andy wrote: > > Hi ! > > > > I was wondering if there are any guidelines how to write code in FreeBSD. > > I have taken a look at several code of FreeBSD but each is written > > differently? Problem is I don't know which is preferred way. > > > > Reason I am asking this is that I am trying to add some code to kernel. > > Compile is OK, no error, no warning, but on link all variables defined > > with extern are marked as : undefined reference to 'variable', variable > > is extern and .h file which has it defined is included... Where can be > > the problem?? Another problem is that I get multiple definition > > error...how can I get over this. I got Andy to send his original code, and I believe that I've diagnosed the root of the problem: The code was assuming that KERNEL was defined when building the kernel (I gather that KERNEL is defined when building a Linux kernel), but under FreeBSD, it seems, KERNEL is *not* defined, but _KERNEL is defined instead. (Though I'm not sure whether it's defined under the same circumstances.) Even so I'm not sure that his code is perfectly correct ANSI C, technically speaking, since it then appears that it would wind up with multiple copies of the variables defined, but I'm pretty darn sure that gcc & ld tolerate this just fine--the proximate cause of the difficulty lay in expecting KERNEL to be defined and having an #ifdef KERNEL check in the 'h' file that caused the definitions to never to be read. -- Brian T. Schellenberger . . . . . . . bts@wnt.sas.com (work) Brian, the man from Babble-On . . . . bts@babbleon.org (personal) ME --> http://www.babbleon.org http://www.eff.org <-- GOOD GUYS --> http://www.programming-freedom.org 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?20020304130608.9A2CDBA03>