* g++ default options/flags
@ 2007-11-15 7:07 kyp44
2007-11-15 9:43 ` Brian Dessent
2007-11-15 16:38 ` John (Eljay) Love-Jensen
0 siblings, 2 replies; 3+ messages in thread
From: kyp44 @ 2007-11-15 7:07 UTC (permalink / raw)
To: gcc-help
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.
--
View this message in context: http://www.nabble.com/g%2B%2B-default-options-flags-tf4809633.html#a13761339
Sent from the gcc - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: g++ default options/flags
2007-11-15 7:07 g++ default options/flags kyp44
@ 2007-11-15 9:43 ` Brian Dessent
2007-11-15 16:38 ` John (Eljay) Love-Jensen
1 sibling, 0 replies; 3+ messages in thread
From: Brian Dessent @ 2007-11-15 9:43 UTC (permalink / raw)
To: kyp44; +Cc: gcc-help
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 config.site 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.
Brian
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: g++ default options/flags
2007-11-15 7:07 g++ default options/flags kyp44
2007-11-15 9:43 ` Brian Dessent
@ 2007-11-15 16:38 ` John (Eljay) Love-Jensen
1 sibling, 0 replies; 3+ messages in thread
From: John (Eljay) Love-Jensen @ 2007-11-15 16:38 UTC (permalink / raw)
To: kyp44, gcc-help
Hi kyp44,
Expounding upon Brian's response, here's how I've done exactly what you are asking to do. I'm assuming a Unix-ish system.
Here are the steps I've done, verbatim (replace -Wall -Wextra with whatever you need):
cd ~
mkdir bin
cd bin
cat > g++ <<EOF
/usr/bin/g++ -Wall -Wextra "$@"
EOF
chmod a+x g++
PATH=~/bin:$PATH
Adjust as necessary. Voila!
HTH,
--Eljay
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-11-15 14:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-15 7:07 g++ default options/flags kyp44
2007-11-15 9:43 ` Brian Dessent
2007-11-15 16:38 ` John (Eljay) Love-Jensen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).