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]

Re: libstdc++, how to set gcc on a multithread environment ?


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


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