0

I'm using Cygwin, and have installed all the developer packages as well as most if not all of the other packages. When I provide an alias for gcc, I get the error

-bash: alias: gcc: not found

What could I be doing wrong?

I am typing the following command into the terminal:

alias gcc "gcc -ansi -Wall -g -O0 -Wwrite-strings -Wshadow -pedantic-errors -fstack-protector-all"

FYI, this alias works on other systems.

  • 1
    What do you mean by "provide an alias for"? What command are you typing, exactly? – steeldriver Feb 14 '16 at 2:33
  • @steeldriver I am typing the following command into the terminal: alias gcc "gcc -ansi -Wall -g -O0 -Wwrite-strings -Wshadow -pedantic-errors -fstack-protector-all" – Joel Feb 14 '16 at 3:46
5

Your alias assignment syntax is wrong for bash/zsh/fish (your syntax is tcsh), you need a = between alias name and alias expansion:

alias gcc="gcc -ansi -Wall -g -O0 -Wwrite-strings -Wshadow -pedantic-errors -fstack-protector-all"

If you omit the =, bash interprets gcc and `"gcc -ansi ..." as two alias names and tries to list their definitions. Since those aliases aren't defined, you get the warning:

bash: alias: gcc: not found
bash: alias: gcc -ansi -Wall -g -O0 -Wwrite-strings -Wshadow -pedantic-errors -fstack-protector-all: not found
  • I spent the whole afternoon trying to solve what you just answered in a second! You don't know how much this means to me. Thanks! – Joel Feb 14 '16 at 4:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.