What's the point of including -std=c++0x in a G++ compile command?

后端 未结 3 1135
失恋的感觉
失恋的感觉 2021-01-15 02:16

I have recently started learning C++ and, since I\'m on Linux, I\'m compiling using G++.

Now, the tutorial I\'m following says

If you happen t

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-15 02:53

    Source for your reference:

    main.cpp

    #include 
    using namespace std;
    
    int main()
    {
        cout << "Test main CPP" << endl;
        return 0;
    }
    

    build.sh

    rm demoASI*
    echo "**cleaned !!**"
    
    ##### C++ 11 Compliance #####
    # type ONE
    g++ -o demoASI_1 -std=c++0x main.cpp
    echo "**rebuild-main-done (C++ 11 Compilation) !**"
    
    # type TWO
    g++ -o demoASI_2 -std=c++11 main.cpp
    echo "**rebuild-main-done (C++ 11 Compilation) !**"
    
    ##### C++ 11+ Compliance #####
    # type THREE
    g++ -o demoASI_3 -std=c++1y main.cpp
    echo "**rebuild-main-done (C++ 11+ (i.e. 1y, but not C++14) Compilation) !**"
    
    ###### C++ 14 Compliance  ######
    # type FOUR
    g++ -o demoASI_4 -std=c++14 main.cpp
    if [ $? -eq 0 ]
    then
        echo "**rebuild-main-done (C++ 14 Compilation) !** :: SUCCESS"
    else
        echo "**rebuild-main-done (C++ 14 Compilation) !** :: FAILED"
    fi
    

    Now, execute the script as; ./build.sh (assuming build.sh has execution permission)

    You can first check the version of your g++ compiler, as;

    g++ --version

    The version of g++, after 4.3, has support for the c++11.

    Please see, for c++14 support info in compiler.

提交回复
热议问题