This is the mail archive of the libc-alpha@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]

Building libstdc++ with current glibc, NULL and pthread.h


I've observed another problem building libstdc++ with current glibc (given 
the gets fix that is now in current libstdc++).  I see errors of the form:

gthr-default.h:681:48: error: 'NULL' was not declared in this scope

which it appears did not appear before because pthread.h, included by 
gthr-posix.h, included time.h to get all the definitions therefrom 
(including NULL) - but

commit 4efeffc1d583597e4f52985b9747269e47b754e2
Author: Ulrich Drepper <drepper@gmail.com>
Date:   Sun Feb 26 13:17:27 2012 -0500

    Fix up POSIX testing in conformtest

restricted it to including time.h with __need_* macros defines, so that 
NULL is no longer provided by pthread.h.

The wording in POSIX about time.h being included by pthread.h is somewhat 
odd, "Inclusion of the <pthread.h> header shall make symbols defined in 
the headers <sched.h> and <time.h> visible.".  At face value it says 
time.h should be included without __need_*; certainly it's OK to do so, 
and so it probably makes sense to do so - or at least, to make sure NULL 
is defined - to keep past GCC versions working.  (I don't know the impact 
on use of installed headers, but the gthr-* headers *do* get installed and 
included by installed headers providing public interfaces.)

I raised the question on the Austin Group list thus:

  The specification of pthread.h says "Inclusion of the <pthread.h> header 
  shall make symbols defined in the headers <sched.h> and <time.h> 
  visible.".  This wording "shall make symbols ... visible" seems unusual - 
  does it mean *all* symbols from those headers?  An arbitrary subset?  It 
  contrasts with the more normal "may make visible" as in signal.h, 
  "Inclusion of the <signal.h> header may make visible all symbols from the 
  <time.h> header.", or "shall include the headers", as in tgmath.h.

  The change history says "IEEE PASC Interpretation 1003.1 #86 is applied, 
  allowing the symbols from <sched.h> and <time.h> to be made visible when 
  <pthread.h> is included. Previously this was an XSI option." but that 
  doesn't provide the rationale for "shall" rather than "may".

-- 
Joseph S. Myers
joseph@codesourcery.com


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