[cfe-dev] Clang++ always defines _GNU_SOURCE

Ismail Donmez via cfe-dev cfe-dev at lists.llvm.org
Tue Jun 14 02:59:29 PDT 2016


Hi,

On Tue, Jun 14, 2016 at 12:54 PM, Lei Zhang via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
> 2016-06-14 16:54 GMT+08:00 Eric Fiselier <eric at efcs.ca>:
>>>  Does libc++ also rely on this macro to work on Linux?
>>
>> Yes. Adding -U_GNU_SOURCE during the libc++ build results in a litany of
>> errors.
>> The libc++ headers depend on a number of C library symbols that only get
>> defined when -D_GNU_SOURCE=1 is present.
>
> Is it feasible to use some finer-grain control like _ISOC99_SOURCE,
> instead of resorting to the too versatile _GNU_SOURCE?
>
> I'd be willing to work out such a patch to libc++, if it makes sense.

Note that _GNU_SOURCE is more extensive:

(from glibc's features.h)

/* If _GNU_SOURCE was defined by the user, turn on all the other features.  */
#ifdef _GNU_SOURCE
# undef  _ISOC95_SOURCE
# define _ISOC95_SOURCE 1
# undef  _ISOC99_SOURCE
# define _ISOC99_SOURCE 1
# undef  _ISOC11_SOURCE
# define _ISOC11_SOURCE 1
# undef  _POSIX_SOURCE
# define _POSIX_SOURCE  1
# undef  _POSIX_C_SOURCE
# define _POSIX_C_SOURCE    200809L
# undef  _XOPEN_SOURCE
# define _XOPEN_SOURCE  700
# undef  _XOPEN_SOURCE_EXTENDED
# define _XOPEN_SOURCE_EXTENDED 1
# undef  _LARGEFILE64_SOURCE
# define _LARGEFILE64_SOURCE    1
# undef  _DEFAULT_SOURCE
# define _DEFAULT_SOURCE    1
# undef  _ATFILE_SOURCE
# define _ATFILE_SOURCE 1
#endif

Regards,
ismail



More information about the cfe-dev mailing list