_BSD_SOURCE vs. __BSD_VISIBLE

Archie Cobbs archie at dellroad.org
Thu Mar 18 14:33:31 PST 2004


Hi,

Apologies if this is an old question, searching the archives didn't yeild
any answers.

All I'm trying to do is write some portable code :-)

Here "portable" simply means that it compiles on both FreeBSD and Linux.
In order to get the various functions I need I have to set a bunch of flags.

On Linux, these flags do the trick (taken from configure.in):

    AC_DEFINE(_XOPEN_SOURCE, 600, XOpen functions)
    AC_DEFINE(_GNU_SOURCE, 1, GNU functions)
    AC_DEFINE(_BSD_SOURCE, 1, BSD functions)
    AC_DEFINE(_ISOC99_SOURCE, 1, ISO C99 functions)
    AC_DEFINE(_POSIX_VERSION, 200112, POSIX version)
    AC_DEFINE(_POSIX_C_SOURCE, 200112, POSIX functions)

On FreeBSD, _BSD_SOURCE is not recognized, but _POSIX_C_SOURCE is and
it actually causes the BSD functions to be hidden. So I have to manually
add __BSD_VISIBLE to get them on FreeBSD.

Q1: Why does Linux require _BSD_SOURCE but FreeBSD requires __BSD_VISIBLE?
Q2: Is there some standard for these flags documented somewhere?
Q3: What is the right and portable set of flags to use?

Any enlightenment is greatly appreciated.

Thanks,
-Archie

P.S. Please CC: me as I'm not on this list.

__________________________________________________________________________
Archie Cobbs      *        CTO, Awarix        *      http://www.awarix.com


More information about the freebsd-standards mailing list