Solved

Using Alias to make gcc compiling always include -Wall

Posted on 2009-05-15
3
752 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 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
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…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

777 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