This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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]

_REENTRANT defined, regardless of -pthread


I filed this as a bug, but it was closed by pinskia
because it was done 'on purpose'. [Bug other/11953]

I think this must be a mistake and protest against it!

Third party C/C++ code depends on the macro _REENTRANT
to know if the code requires thread-safety or not.

Using gcc version 3.4 20030816 (experimental),
this is the required behaviour:

~>echo | g++-cvs-3.4          -E -dM -c - > singlethreaded
~>echo | g++-cvs-3.4 -pthread -E -dM -c - > multithreaded
~>diff -u singlethreaded multithreaded
--- singlethreaded      2003-08-17 12:37:57.843906040 +0200
+++ multithreaded       2003-08-17 12:38:09.182182360 +0200
@@ -26,6 +26,7 @@
 #define __DECIMAL_DIG__ 21
 #define __gnu_linux__ 1
 #define __LDBL_HAS_QUIET_NAN__ 1
+#define _REENTRANT 1
 #define __GNUC__ 3
 #define __DBL_MAX__ 1.7976931348623157e+308
 #define __DBL_HAS_INFINITY__ 1

But, when we include for example <iostream> or <iosfwd>,
then mainline suddenly defines _REENTRANT regardless!

~>echo "#include <iosfwd>" > troep.cc
~>g++-cvs-3.4 -E -c troep.cc -dM | grep REENTRANT
#define _REENTRANT 1
[...]

Is that really intentional?

If so, then how is one supposed to know when -pthread was
used and when not?  Or those applications that explicitely
give -D_REENTRANT on the commandline - that cannot be
detected either anymore in the normal way.  One could
test on _REENTRANT *before* including any headerfile,
but this will break a lot of code imho.

-- 
Carlo Wood <carlo@alinoe.com>


PS Why does this not work?
   echo "#include <iosfwd>" | g++-cvs-3.4 -E -c -
   It gives:
   <stdin>:1:18: iosfwd: No such file or directory


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