开发者

g++ and c++0x specification support

开发者 https://www.devze.com 2022-12-27 02:53 出处:网络
although it\'s been said that the support for c++0x new features in g++ are in experimental mode, many gcc developer claimed that you can use most of the new features in your codes and get th开发者_JA

although it's been said that the support for c++0x new features in g++ are in experimental mode, many gcc developer claimed that you can use most of the new features in your codes and get th开发者_JAVA技巧e program to work.

but when I try to compile this simple program it results in segmentation fault. Why?

#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


I linked the executable with pthread library and it worked! I did not see any missing shared library dependency (ldd), but seems like std C++ library implementation on Linux uses pthread internally.

g++ thread.cpp -o thread -Wall -std=c++0x -lpthread
0

精彩评论

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