Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

g++ and c++0x specification support

Tags:

c++

gcc

c++11

g++

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 the 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

like image 672
sepisoad Avatar asked Apr 18 '10 22:04

sepisoad


People also ask

Does GCC support c++ 20?

C++20 Support in GCCGCC has experimental support for the latest revision of the C++ standard, which was published in 2020. C++20 features are available since GCC 8.

Does GCC support c++ 17?

GCC has had complete support for C++17 language features since version 8. Clang 5 and later supports all C++17 language features. Visual Studio 2017 15.8 (MSVC 19.15) and later supports all C++17 language features.

What version of GCC supports C ++ 11?

Status of Experimental C++11 Support in GCC 4.8 GCC provides experimental support for the 2011 ISO C++ standard. This support can be enabled with the -std=c++11 or -std=gnu++11 compiler options; the former disables GNU extensions.

How GCC works in c++?

1.7 GCC Compilation ProcessGCC compiles a C/C++ program into executable in 4 steps as shown in the above diagram. For example, a " gcc -o hello.exe hello. c " is carried out as follows: Pre-processing: via the GNU C Preprocessor ( cpp.exe ), which includes the headers ( #include ) and expands the macros ( #define ).


1 Answers

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
like image 95
Sumant Avatar answered Oct 22 '22 21:10

Sumant