_BSD_SOURCE vs. __BSD_VISIBLE

Garrett Wollman wollman at khavrinen.lcs.mit.edu
Thu Mar 18 15:07:10 PST 2004


<<On Thu, 18 Mar 2004 16:33:25 -0600 (CST), Archie Cobbs <archie at dellroad.org> said:

> 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.

Then your code is wrong.  If you don't want POSIX namespace, then you
shouldn't be defining _POSIX_C_SOURCE.

Application code has no business defining __BSD_VISIBLE.

> Q1: Why does Linux require _BSD_SOURCE but FreeBSD requires __BSD_VISIBLE?

Because Linux (or more likely, glibc) made a bad decision.

> Q3: What is the right and portable set of flags to use?

None, unless your application is prepared to live within the
limitations of the namespaces it requests.  Don't ask for POSIX and
then expect something else.

-GAWollman



More information about the freebsd-standards mailing list