This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: g++ default options/flags

kyp44 wrote:

> 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 file with the
desired settings.

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]