_BSD_SOURCE vs. __BSD_VISIBLE

Archie Cobbs archie at dellroad.org
Thu Mar 18 15:32:02 PST 2004


Garrett Wollman wrote:
> > 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.

So you're saying that _POSIX_C_SOURCE is not an additive thing,
it's a restrictive thing.

This is different semantics from other flags (which serve to include
symbols rather than omit them), which is contributing to my confusion.
E.g. _GNU_SOURCE on Linux.

Are these flags documented somewhere?

> > Q1: Why does Linux require _BSD_SOURCE but FreeBSD requires __BSD_VISIBLE?
> 
> Because Linux (or more likely, glibc) made a bad decision.

Can you elaborate?

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

I want everything.. on Linux I need at least _GNU_SOURCE to get it,
otherwise my compilation fails due to undeclared stuff. Why did Linux
choose to arrange things so that the "default" is to not show everything?
Don't just say they made a "bad decision".. they must have had some
rationale, even if flawed.

-Archie

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


More information about the freebsd-standards mailing list