This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: libstdc++, how to set gcc on a multithread environment ?
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Jose Luis Marchetti <joseluismarchetti at yahoo dot com dot br>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Sun, 26 Jul 2009 23:57:27 +0100
- Subject: Re: libstdc++, how to set gcc on a multithread environment ?
- References: <617720.52030.qm@web34403.mail.mud.yahoo.com>
2009/7/26 Jose Luis Marchetti:
>
> Hi,
>
> After reading gcc documentation and this link:http://gcc.gnu.org/onlinedocs/libstdc++/manual/using_concurrency.html, I am not sure of:
>
> 1) Only adding -pthread option when invoking gcc suffices ?
Suffices for what? Your question isn't clear.
> Here is what gcc documentation says:
> -pthread Add support for multithreading using the POSIX threads library. This option
> sets flags for both the preprocessor and linker. It does not affect the thread
> safety of object code produced by the compiler or that of libraries supplied with
> it.
>
>
> 2) I have already added the pthread lib on my link, but it looks like I also need to add the -pthread option to the compiler.
Yes, probably.
> 3) The link I showed above says:
> "Allocators called while a container or element is constructed uses an internal lock obtained and released solely within libstdc++ code (in fact, this is the reason STL requires any knowledge of the thread configuration)."
>
> So this is the reason we need to use the -pthread option when invoking gcc ? Any other reason ?
Depending on the platform, the -pthread option might affect the
preprocessor, e.g. defining _REENTRANT, and that can affect the C
library, and other libraries, so using -pthread can affect many
things.
Jonathan