Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Mar 2004 16:33:25 -0600 (CST)
From:      Archie Cobbs <archie@dellroad.org>
To:        freebsd-standards@freebsd.org
Subject:   _BSD_SOURCE vs. __BSD_VISIBLE
Message-ID:  <200403182233.i2IMXPuJ002724@arch20m.dellroad.org>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200403182233.i2IMXPuJ002724>