Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 776
  • Last Modified:

Using Alias to make gcc compiling always include -Wall

I am taking my first true dive into Linux and Unix after using it one of my CS classes so I'm certainly new to this, as such I'm having some trouble with command.

I would like to do an alias command to make it so everytime I do a 'gcc filename' from the terminal it automatically adds the -Wall tag, giving 'gcc -Wall filename'.  The biggest problem I'm having is not knowing how to use a variable inside of the alias command.  I realize this is just laziness on my part but figuring out how to do this would go a long way to my understanding too =)
0
Asturias2789
Asked:
Asturias2789
  • 2
2 Solutions
 
woolmilkporcCommented:
You don't need a variable for your purpose. Your parameters will get appended to the alias.
Just do-
alias gccw="gcc -Wall" That's it. Place this statement in your .profile to have it active at every login.
wmp
 
0
 
woolmilkporcCommented:
... you can also use
alias gcc="gcc -Wall"
alias will recognize the difference between the alias 'gcc' and the executable 'gcc' and will not enter an infinite loop.
 
0
 
omarfaridCommented:
alias is ok as long as your shell support it. You could also add new command to /usr/bin dir (e.g. cc) which contains:

gcc -Wall $*

this script or new command will be available to all users
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now