next up previous
Next: Libraries and Header Files Up: intro_C Previous: Basic Rules


Most platforms these days have native C compilers (usually called cc) as well as one or more third-party C compilers, the most common being gcc, the Gnu C compiler. Native compilers differ in their argument syntax; check the man pages if in doubt. Compiling can be as simple as cc myprog.c (which produces an executable version called a.out) or more complex like cc -O2 -o myprog myprog.c -lm (which names the executable myprog, applies second-level optimization, and links to the math library). If an error is encountered during the compilation, a message will appear indicating the nature of the problem and the offending line number in the code.

Hint: Always fix the first reported error first! Often one error (e.g. forgetting a semi-colon or closing brace) generates many more, making it seem like the code is full of problems when in fact there is just one simple typo.

Massimo Ricotti 2009-01-26