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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…