C/Warnings and Errors

From Linux Hints

Jump to: navigation, search

I always encourage novice programmers to try and use as strong warnings to GCC as possible. At the very least, use -Wall:

gcc -c program.c -Wall -O2

Note that GCC can only spot certain types of issues when it does extra analysis associated with the optimization flags (-O2, -O3). This includes uninitialized variables in some situations.

If you're up to it, add:

-W -pedantic

Spotting and fixing issues early on can save considerable time in maintenance and debugging later on.

Personal tools
related