GCC includes over 30 individual warnings and three "catch-all" warning levels. GCC is also a cross-compiler, so you can develop code on one processor architecture that will be run on another. Finally, GCC sports a long list of extensions to C and C++. Most of these
extensions enhance performance, assist the compiler's efforts at code optimization, or make your job as a programmer easier. The price is portability, however.
This program will compute the reciprocal of an integer. http://siber.cankaya.edu.tr/SystemsProgramming/cfiles/main.cmain.c
#include <stdio.h>
#include <stdlib.h>
#include "reciprocal.hpp"
int main (int argc, char **argv)
{
int i;
i = atoi (argv[1]);
printf ("The reciprocal of %d is %g\n", i, reciprocal (i));
return 0;
}
http://siber.cankaya.edu.tr/SystemsProgramming/cfiles/reciprocal.cppreciprocal.cpp
#include <cassert>
#include "reciprocal.hpp"
double reciprocal (int i) {
// I should be non-zero.
assert (i != 0);
return 1.0/i;
}
There is also one header file called http://siber.cankaya.edu.tr/SystemsProgramming/cfiles/reciprocal.hppreciprocal.hpp
#ifdef __cplusplus
extern "C" {
#endif
extern double reciprocal (int i);
#ifdef __cplusplus
}
#endif
The first step is to turn the C and C++ source code into object code.