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

Jose Luis Marchetti joseluismarchetti@yahoo.com.br
Sun Jul 26 11:27:00 GMT 2009


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 ?
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.

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 ?

Thanks in advance!
José Luís Marchetti


      ____________________________________________________________________________________
Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com



More information about the Libstdc++ mailing list