Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using Alias to make gcc compiling always include -Wall

Posted on 2009-05-15
3
Medium Priority
?
768 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 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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

715 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