============================== Using the GNU C-Compiler (GCC) ============================== Compiling and running a first C program ======================================= :import: session03/factorial.c Compile (read but ignore the warning for the moment) and run the program with ---- SHELL(path=session03) ---------------------- gcc -Wall -std=c99 -o factorial factorial.c factorial ------------------------------------------------- Examine the generated assembly code =================================== Check out the generated assembly code with ---- SHELL(path=session03,hostname=heim) ---------------------- gcc -Wall -std=c99 -S -fomit-frame-pointer -fno-asynchronous-unwind-tables factorial.c ------------------------------------------------- Note that the parameters `-fomit-frame-pointer` and `-no-fasynchronous-unwind-tables` are just used here for the sake of simplicity. The assembly code generated is stored in file `factorial.s`: ---- SHELL(path=session03) ---------------------- cat factorial.s ------------------------------------------------- Examine the result of the C Preprocessor (CPP) ============================================== Check the output of the CPP for the C program :import: session03/factorial2.c Use the option `-E` so that `gcc` just calls the CPP and then stops (so any other options for `gcc` can be omitted): ---- SHELL(path=session03) ---------------------- gcc -E factorial2.c ------------------------------------------------- Getting rid of the warning ========================== - First check the result of CPP (just to see once what the `#include` does) - Compile and run the program with `gcc -Wall -std=c99 -o factorial3 factorial3.c` - Compile and run the program with `gcc -DN=10 -Wall -std=c99 -o factorial3 factorial3.c` :import: session03/factorial3.c Types `size_t` and `ptrdiff_t` ============================== - Compile and run :import: session03/factorial4.c - Complete the following code :import: session03/globalvars.c - Change the previous code such that variables `a`, ..., `f` are now local variables. Compile and run the code. :navigate: up -> doc:index next -> doc:session03/page02