Style(9) and portability

Garance A Drosihn drosih at rpi.edu
Sat Mar 6 17:06:45 PST 2004


At 12:18 PM -0800 3/6/04, Tim Kientzle wrote:
>... I've been scratching my head over how to
>deal with the version ID code that is supposed
>to apear as the first two lines of any FreeBSD
>source file:
>
>#include <sys/cdefs.h>
>__FBSDID("$FreeBSD$");
>
>Clearly, I cannot reasonably assume that all
>platforms define a __FBSDID macro in sys/cdefs.h.

Really, you can't even assume that all platforms
will *have* a sys/cdefs.h

>The second option deals with the issue by pushing
>it onto a header that encapsulates platform-specific
>definitions.  In particular, the local platform.h
>header can include sys/cdefs.h on FreeBSD and
>provide an alternative definition of __FBSDID
>on other platforms.  The drawback is, of course,
>the requirement for a new local header file to
>wrap platform-specific decisions:
>
>2)  #include "platform.h"   /* Platform-specific defines */
>     __FBSDID("$FreeBSD$");

This is basically the tactic that I went with for
everything under lpr.  That works reasonably well
for lpr, but I don't know if it makes sense for
everything:

#include "lp.cdefs.h"  /* A cross-platform version of <sys/cdefs.h> */

I intentionally have the comment about sys/defs.h,
in case someone comes along later and scans for
that string...

-- 
Garance Alistair Drosehn            =   gad at gilead.netel.rpi.edu
Senior Systems Programmer           or  gad at freebsd.org
Rensselaer Polytechnic Institute    or  drosih at rpi.edu


More information about the freebsd-hackers mailing list