开发者

gcc difference between -pthread and -pthreads?

开发者 https://www.devze.com 2022-12-13 12:46 出处:网络
I have a pthreads program. I have to compile it with gcc -pthread in Linux (-pthreads is unrecognized option) and gcc -pthreads in Sun 开发者_如何学运维(-pthread is unrecognized option). Why the diffe

I have a pthreads program. I have to compile it with gcc -pthread in Linux (-pthreads is unrecognized option) and gcc -pthreads in Sun 开发者_如何学运维(-pthread is unrecognized option). Why the difference, since it's the same compiler? However, -lpthread works on both, but I heard this isn't always sufficient.


The Solaris -pthreads and Linux -pthread options do equivalent things. Apparently, gcc-4.x series accepts -pthread for Solaris as well.

You do want the -pthread/-pthreads option while compiling because it adds multithreading support in the preprocessor and the linker.

0

精彩评论

暂无评论...
验证码 换一张
取 消