[Bug 257827] Providing _POSIX_C_SOURCE causes some C++ headers to fail

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 14 Aug 2021 01:25:09 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=257827

--- Comment #2 from Chris Spiegel <cspiegel@gmail.com> ---
If _POSIX_C_SOURCE is invalid for C++, then agreed, this whole bug is invalid.
Moreover, given that _XOPEN_SOURCE includes _POSIX_C_SOURCE (i.e. if you define
_XOPEN_SOURCE it's equivalent to defining the corresponding _POSIX_C_SOURCE),
it seems that neither of these can/should be set while using C++.

Just for some information, I found that Oracle's Solaris posix(5) man page says
this:

"C++ bindings are not defined for POSIX or X/Open CAE, so specifying feature
test macros such as _POSIX_SOURCE, _POSIX_C_SOURCE, and _XOPEN_SOURCE can
result in compilation errors due to conflicting requirements of standard C++
and those specifications."
(https://docs.oracle.com/cd/E86824_01/html/E54776/posix-5.html)

Does all of this imply that it's invalid to call POSIX code from C++?  On
FreeBSD, at least, it "works" just fine if you define _XOPEN_SOURCE for C++,
but of course that might be incidental, given that _POSIX_C_SOURCE alone causes
this failure (it's valid in general to ask for POSIX support without the XSI
extension, e.g. to defined only _POSIX_C_SOURCE).

-- 
You are receiving this mail because:
You are the assignee for the bug.