dpr
dpr

Reputation: 1

Is there a way to make a c++ compiler flag as default

Just like we specify input flags in the settings of the project in Xcode

Can I make few flags like -O3 or -fopenmp as default flags in command line when I use Terminal.
So that I dont have to type them everytime I compile some c++ fies. Is there a file in the installed gcc or C++ that I can edit to make them default. Please let me know thanks

Upvotes: 0

Views: 993

Answers (1)

wkl
wkl

Reputation: 80001

For situations like this you'd probably use a makefile if it's project specific (or other similar automated build management like scons or cmake).

If you want it always on the terminal, you can alias your command to always specify those options, i.e.

alias g++='g++ -O3 -fopenmp'

Note that you said 'terminal' so I assume this is a type of *nix. If that is the case you can also set this into your terminal profile, like ~/.bashrc if you use bash, or ~/.zshrc if you use zsh, etc.

Upvotes: 2

Related Questions