This is the mail archive of the
mailing list for the GCC project.
Re: g++ default options/flags
- From: Brian Dessent <brian at dessent dot net>
- To: kyp44 <kyp4 at yahoo dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Wed, 14 Nov 2007 23:07:09 -0800
- Subject: Re: g++ default options/flags
- References: <email@example.com>
- Reply-to: gcc-help at gcc dot gnu dot org
> After searching pretty extensively the web and nabble I could not find the
> answer to what I think ought to be a simple question: is there a way to
> change the default options/flags so that every time g++ is invoked
> additional, default flags are added to those flags passed with the command?
> In my particular example I need to have the -ffriend-injection flag passed
> every time I call g++ and I don't want to have to add it to all my
> makefiles. I am fairly new to linux and I tried making an alias (alias
> g++='g++ -ffriend-injection') but this did not work when g++ is called from
> make, which I guess makes sense since it is not executed as a command to
> bash. Any help with this would be appreciated.
Any properly written Makefile should provide the user a way to specify
things like CXXFLAGS in the environment or when invoking make. For
autoconf based packages you can create a config.site file with the
If that's not enough you can create a wrapper script for g++ and put it
ahead of the actual g++ in the PATH. Alternatively, you could edit the
gcc specs file. But these are both horribly ugly solutions -- the
various *FLAGS are meant to be the domain of the user, not the package,
so it's a bug in the package if they can't be reasonably set somehow;
editing a bunch of Makefiles should never be necessary.