[英]g++ and c++0x specification support
雖然據說g ++中對c ++ 0x新功能的支持處於實驗模式,但許多gcc開發人員聲稱可以使用代碼中的大多數新功能並使程序正常工作。
但是當我嘗試編譯這個簡單的程序時,會導致分段錯誤。 為什么?
#include <thread>
#include <iostream>
void my_thread_func()
{
std::cout<<"hello"<<std::endl;
}
int main()
{
std::thread t(my_thread_func);
t.join();
}
g ++ -std = c ++ 0x -Wall -o run main.cc
我將可執行文件與pthread庫鏈接起來並且有效! 我沒有看到任何遺漏的共享庫依賴項(ldd),但似乎Linux上的std C ++庫實現在內部使用pthread。
g++ thread.cpp -o thread -Wall -std=c++0x -lpthread
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.