C/Warnings and Errors

From Linux Hints

Revision as of 11:16, 25 June 2010 by Puffin (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
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