-ansi and pthread.h in glibc-2.0
Klaus-Georg Adams
Klaus-Georg.Adams@chemie.uni-karlsruhe.de
Thu Jun 11 06:53:00 GMT 1998
Jason wrote:
[ Tests failing on glibc-2.0 systems because of incompatibilities
between g++ -ansi and /usr/include/pthread.h ]
> > Based on that clue, I was able to add 'Special g++ Options:" lines
> > to the two tests and make them work. That is apparently the cause
> > of many of the failures on my RH5 box. Is adding this line to all
> > the failing tests (to nuke the "special options") really the best way
> > to do this?
>
> No. The problem is in the glibc headers. Here's the workaround I use:
>
> Index: libstdc++/stl/stl_config.h
> ===================================================================
> RCS file: /egcs/carton/cvsfiles/egcs/libstdc++/stl/stl_config.h,v
> retrieving revision 1.5
> diff -c -p -r1.5 stl_config.h
> *** libstdc++/stl/stl_config.h 1998/02/20 11:13:42 1.5
> --- libstdc++/stl/stl_config.h 1998/06/10 07:49:36
> ***************
> *** 114,121 ****
> # define __STL_EXPLICIT_FUNCTION_TMPL_ARGS
> # define __STL_MEMBER_TEMPLATES
> # endif
> ! # if !defined(_NOTHREADS) && __GLIBC__ >= 2
> # define __STL_PTHREADS
> # endif
> # ifdef __EXCEPTIONS
> # define __STL_USE_EXCEPTIONS
> --- 114,127 ----
> # define __STL_EXPLICIT_FUNCTION_TMPL_ARGS
> # define __STL_MEMBER_TEMPLATES
> # endif
> ! /* glibc pre 2.0 is very buggy. We have to disable thread for it.
> ! It should be upgraded to glibc 2.0 or later. */
> ! # if !defined(_NOTHREADS) && __GLIBC__ >= 2 && defined(_G_USING_THUNKS)
> # define __STL_PTHREADS
> + # ifdef __STRICT_ANSI__
> + /* Work around a bug in the glibc pthread.h. */
> + # define sigset_t __sigset_t
> + # endif
> # endif
> # ifdef __EXCEPTIONS
> # define __STL_USE_EXCEPTIONS
I think this is a wrong approach. If you compile with -ansi you should
not include pthread.h. Ansi doesn't know threads, and if you want
Ansi, you have to disable threads.
Or if you include it anyways, you have to define _POSIX_SOURCE or
_BSD_SOURCE or whatever is required to make pthread.h work correctly,
but kludging around is not a long-term solution.
-- kga
-------------------------------------------------------------------------
Klaus-Georg Adams Email: Klaus-Georg.Adams@chemie.uni-karlsruhe.de
Institut f. Anorg. Chemie, Lehrstuhl II Tel: 49(0)721 608 3485
Universität Karlsruhe, D-76128 Karlsruhe
-------------------------------------------------------------------------
More information about the Gcc-bugs
mailing list