Advertisement Jump to content
Sign in to follow this  
xeyedmary

Reentrant flag passing

This topic is 721 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Confining this to GNU C/C++ 5.4.0 for simplicity, I don't have access to llvm/clang or intel or msvc, not too sure it matters.

 

So I was given to believe that including pthreads (using cmake I'm linking via "set ( PROJECT_LINK_LIBS pthread )" in with a very simple test example, testing some thoughts on C++11 threads) defined the _REENTRANT macro after reading this and that on net. So, since seeing is believing I just spun up a simple test case:

#ifdef _REENTRANT
	cout << "-------------------> reentrant " << endl;
#endif

in a POCO constructor, and added it to the code. To my jaded surprise the line didn't get printed out. As soon as I actually passed -D_REENTRANT to the compiler invocation it of course got printed. Anyone got the skinny on this behavior with 5.4.0? Did I "do it wrong"? Am I reading the spec (or, actually, the gcc list of expected behaviors) incorrectly?

Share this post


Link to post
Share on other sites
Advertisement

My guess is that it's just an issue with your CMake configuration. Depending on your version of CMake, there are several idiomatic ways to link against pthreads. See cmake and libpthread.

Yep. Since CMake 2.8.12 we need to add

add_compile_options(-pthread)

and done.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!