Change default C++ standard in g++

后端 未结 1 1913
执念已碎
执念已碎 2020-12-19 02:29

In order to compile a program in C++11 standard we need to do :

 g++ -std=c++11 myProgram.cpp -o myProgramExec

But is it possible that i ca

1条回答
  •  孤城傲影
    2020-12-19 03:11

    After a bit of research (which you've probably already done yourself), I haven't found a way to change the default behavior of g++ other than rebuilding a custom version or aliasing it.


    Why this is probably a good thing:

    It is important that each version of g++ has a single, well-defined default behavior. Consider this: if you change the default behavior of g++ and try to compile a C++ project whose author could not be aware of your configuration, the project may fail to compile or compile with subtle errors / unexpected behaviors.

    In your own project, you can easily add all the relevant flags and options to your Makefile or CMakeLists.txt so that you don't need to type them again. This will also ensure that other people compiling your project will receive the correct options regardless of their configuration.

    0 讨论(0)
提交回复
热议问题