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
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.
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.
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.
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 ).
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With