gcc -pthread 和 -pthreads 之间的区别?

标签 gcc compiler-construction pthreads portability

我有一个 pthreads 程序。我必须使用 Linux 中的 gcc -pthread(-pthreads 是无法识别的选项)和 Sun 中的 gcc -pthreads(-pthread 是无法识别的选项)编译它。为什么不同,因为它是相同的编译器?但是,-lpthread 对两者都有效,但我听说这并不总是足够的。

最佳答案

Solaris -pthreads和 Linux -pthread选项做等效的事情。显然,gcc-4.x系列接受-pthread也适用于 Solaris。

您确实想要 -pthread/-pthreads编译时的选项,因为它在预处理器和链接器中添加了多线程支持。

关于gcc -pthread 和 -pthreads 之间的区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1877702/

相关文章:

gcc - 如何构建/更新 Cygwin GCC?

c - 我在 SPOJ、语言 C、编译器 gcc 4.3.2 中收到以下代码的运行时错误:代码为 :

c - pthread_mutex 和进程终止

c - 另一个进程和线程问题

c++ - 多线程概念题

c - Facebook拼图提交失败

c++ - 忽略无效转换错误,GCC

c - 如何定义编译时 -D 宏 (Apache 2.2)?

c++ - 如何解决重复符号错误?

c - 如果在没有 "__attribute__(align(8))"的情况下声明结构,如何生成警告