The gcc (1) man page can make for daunting reading, and almost no one ever comes to my consulting hour :( so I'm putting some advice about the proper use of the compiler here. Hopefully this will result in students spending less time tracking down small bugs in their programs and make my marking go faster too.
gcc, the Free Software Foundation's C compiler, does not comply with the ISO/ANSI standard unless you include the -pedantic command line switch. (-ansi just turns off various GNU extensions.)
To get the full effect of the built-in error-checking, you need to use -O along with -Wwhatever. I recommend using -Wall -O until you feel you know C, then you should use whatever additional -W switches you feel are appropriate.
The -O switch has to do with optimizing code but it also enables checking for uninitialized variables.
Don't make the mistake of thinking that gcc replaces lint. lint does more (and slightly different) checking than gcc. You will benefit from using both.
I have an example Makefile (in my notes about encapsulation in C) which shows how to include those flags in all your compiles.
SUMMARY: compile using
gcc -ansi -pedantic -Wall -O
This document is copyright by its author, J. Blustein.