This is the mail archive of the glibc-linux@ricardo.ecn.wfu.edu 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]

Re: _GNU_SOURCE, _XOPEN_SOURCE and __USE_UNIX98


>>>>> Jean-Marie Sulmont writes:

 > Hi,
 > Can anybody enlighten me on the usage of __USE_UNIX98 in glibc-2.1.1?
 > To be a little more accurate, I'd like to use the pthread_rwlock_xxxx
 > stuffs (linuxthread-0.8).  According to pthread.h, __USE_UNIX98 must 
 > be defined. 
 > Butenhof seems to be using X/Open XSH5 and UNIX98 interchangably, and
 > then suggests that a system conformance to XSH5 is to be recognized
 > in unistd.h by a definition of _XOPEN_VERSION to 500 or higher.
That's the way it works.

 > There seems to be a little inconsistency, in the following way:
 > unistd.h starts by including features.h which goes like:

 > // from features.h
 > . . .
 > #undef __USE_UNIX98
 > . . . 
 > #ifdef  _XOPEN_SOURCE
 > # define __USE_XOPEN    1
 > # if (_XOPEN_SOURCE - 0) == 500
 > #  define __USE_XOPEN_EXTENDED  1
 > #  define __USE_UNIX98  1
 > #  undef _LARGEFILE_SOURCE
 > #  define _LARGEFILE_SOURCE     1
 > # else
 > #  ifdef _XOPEN_SOURCE_EXTENDED
 > #   define __USE_XOPEN_EXTENDED 1
 > #  endif
 > # endif
 > #endif
 > . . .

 > and then:

 > // from unistd.h
 > . . .
 > #include <features.h>
 > . . .
 > #ifdef __USE_UNIX98
 > # define _XOPEN_VERSION 500
 > #else
 > # define _XOPEN_VERSION 4
 > #endif


 > This last #ifdef should be removed and the only way to get __USE_UNIX98 
 > defined is to define _XOPEN_VERSION to 500 or higher or define 
 > _GNU_SOURCE prior to including unistd.h
You're confusing _XOPEN_SOURCE with _XOPEN_VERSION.  You've got to
define _XOPEN_SOURCE to 500.
 > Now is glibc-2.1.1 compliant to _XOPEN_VERSION 500? Can _GNU_SOURCE
 > be turned on safely?
Have a look at <features.h>, the flags are explained.

and read the manual, section:
* Standards and Portability::   Standards and sources upon which the GNU
                                 C library is based.
and:
* Feature Test Macros::         How to control what names are defined.

Andreas
-- 
 Andreas Jaeger   aj@arthur.rhein-neckar.de    jaeger@informatik.uni-kl.de
  for pgp-key finger ajaeger@aixd1.rhrk.uni-kl.de

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