This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Problems with default _POSIX_C_SOURCE in features.h ??



features.h (in glibc 2.29, 31-Jan-2019) includes:
______________________________________________________________________
/* If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE
   is defined, use POSIX.1-2008 (or another version depending on
   _XOPEN_SOURCE).  */
#ifdef _DEFAULT_SOURCE
# if !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE
#  define __USE_POSIX_IMPLICITLY	1
# endif
# undef  _POSIX_SOURCE
# define _POSIX_SOURCE	1
# undef  _POSIX_C_SOURCE
# define _POSIX_C_SOURCE	200809L
#endif

#if ((!defined __STRICT_ANSI__					\
      || (defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 500))	\
     && !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE)
# define _POSIX_SOURCE	1
# if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 500
#  define _POSIX_C_SOURCE	2
# elif defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 600
#  define _POSIX_C_SOURCE	199506L
# elif defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 700
#  define _POSIX_C_SOURCE	200112L
# else
#  define _POSIX_C_SOURCE	200809L
# endif
# define __USE_POSIX_IMPLICITLY	1
#endif
______________________________________________________________________

But this does not do what the comment says it does :-(

If _DEFAULT_SOURCE is defined, but neither POSIX_SOURCE nor
_POSIX_C_SOURCE are defined, this sets _POSIX_C_SOURCE	200809L,
no matter what _XOPEN_SOURCE is.

Bug #1 ??


Further on in features.h we have:
_______________________________________________________________________
#if defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 2 || \
                                                 defined _XOPEN_SOURCE
# define __USE_POSIX2   1
#endif

#if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 199309L
# define __USE_POSIX199309  1
#endif

#if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 199506L
# define __USE_POSIX199506  1
#endif
_______________________________________________________________________

If, say, _XOPEN_SOURCE == 500 the rules say that it is not necessary to define _POSIX_SOURCE or _POSIX_C_SOURCE, but whatever they are set to, the effect as if _POSIX_C_SOURCE == 199506L (except that if _POSIX_C_SOURCE > 199506L, where the effect is undefined).

Should one or both of __USE_POSIX199309 and __USE_POSIX199506 be set if _XOPEN_SOURCE == 500 ?

Bug #2 ??


In cases where _POSIX_C_SOURCE is bigger than expected for the given _XOPEN_SOURCE the result does seem to be a mess -- but, hey, the standard says it's undefined !

Am I missing something, or should I report these as bugs ?

Chris


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]