Re: What's the effect of #define _REENTRANT

Mark wrote:
I was reading this tutorial at

and the author writes that posix thread coding requires you must

"1. add #include <pthread.h> in your .c or .h header file(s)
2. define the #define _REENTRANT macro somewhere in a common .h or .c file
3. In your Makefile make sure gcc links against -lpthread
4. Optional: add -D_POSIX_PTHREAD_SEMANTICS to your Makefile (gcc flag) for
certain function calls like sigwait()"

I've read many statements on the internet and many are
conflicting about whether _REENTRANT is needed or what.
I'm using solaris 9 X86 with GCC 3.3


As the bug report says, -pthread (and #include <pthread.h>) *should* be
sufficient to portably enable pthreads when using gcc, but it isn't. If
you're using autoconf, the macro linked to from the report can be used as
a workaround. Otherwise you have to know the particular incantation for
your platform, and every platform is different.

For Solaris, see also
<> and

I was curious as to what the symptoms are of posix threaded
code not using reentrant functions when it should.

Undefined behaviour.

David Hopwood <david.nospam.hopwood@xxxxxxxxxxxxxxxx>