You can set an environment variable:
export CXXFLAGS="-Wall -O3 -std=c++11"
and use
g++ $CXXFLAGS test.cc -o test
Note that some variables are more-or-less standardized and when you set them, several build system will automatically use them. Among others, google for CFLAGS
, CPPFLAGS
, CXXFLAGS
, ...
Here's also a starting point on SO.