Are there any caveats or gotchas to aliasing cc
to refer to Clang within my default shell, Z shell (presumably by editing my .zshrc file) while leaving cc
aliased to gcc
in another shell (Bash)?
I find Clang much easier to use, mainly because its warnings and error messages are much more readable and understandable than those of GCC. I will be enrolled in a Unix programming course next semester (purely in C) and am expected to have cleared any GCC -Wall warnings before submission of an assignment.
I am trying to do most of my developing using Clang within my default shell (Z shell) using a makefile that refers to the compiler as just cc
. Once satisfied, I would run it once, as a test, via Bash (invoking GCC as the compiler) before submitting. The submitted makefile with cc
as the compiler would then invoke GCC for the instructor, making it transparent to them. I am supposed to submit makefiles with each assignment.
I know this just seems like laziness since I can re-edit the makefile each time, but I am trying to leave less room for error.
Just run
make CC=clang
or
make CC=gcc
or perhaps
make CC='gcc -flto -Wall'
(A reminder: -flto
should be passed at compile and at link time).