I asked this question originally on StackOverflow. I use
M-x compile within Emacs to compile my C code which then initiates
make -k and allows me to compile the code. I wish to use Clang (or conceivably GCC 4.8 after I install it) as the default compiler. I have
cc aliased to
clang -Wall -Werror -std=c99 -ggdb -O0 and while this invokes
Clang from the command line outside of Emacs, invoking
M-x compile from within Emacs still seems to alias
cc to GCC version 4.7 which is what I have installed. I wish to tap into the richer and more understandable error and warning messages provided by Clang (and GCC 4.8) but do not wish to create a separate makefile for every short student-level program I am writing, since I am currently going through K&R including solving the exercises.
How do I convince Emacs that
M-x compile and
make -k should invoke Clang (or GCC 4.8) instead of the older version of GCC?