[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Build requirements for threaded code?



On 08/19/2009 07:57 PM, Roland McGrath wrote:
-pthread means -D_REENTRANT and -lpthread.  -D_REENTRANT is basically
useless and you should use standard feature test macros or _GNU_SOURCE for
what you want.  So just linking with -lpthread is what I would call the
normal and recommended practice.

On current Fedora with gcc+glibc(NativePosixThreadLibrary) this works today
and has for some years.  On some predecessor systems "gxx -pthread"
was required for both compiling and linking.  [gxx means gcc or g++.]
On non-NPTL or non-Linux systems it may still be required today.
Perhaps it may be required on future Fedora.

Using "gxx -pthread" always is safe.  At least, making it safe is a well-
known part of the job of the maintainer of gxx.  Using just "-lpthread"
means that the user _assumes_ that compilation is independent of threading,
or already has taken threading into account.

--


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]