Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Using Alias to make gcc compiling always include -Wall

Posted on 2009-05-15
3
Medium Priority
?
773 Views
Last Modified: 2013-12-20
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
Comment
Question by:Asturias2789
  • 2
3 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 1200 total points
ID: 24396764
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
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 24396874
... 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
 
LVL 40

Assisted Solution

by:omarfarid
omarfarid earned 800 total points
ID: 24397175
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question