Solved

Using Alias to make gcc compiling always include -Wall

Posted on 2009-05-15
3
758 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 300 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 200 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

Suggested Solutions

I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Suggested Courses

739 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