Make sure you understand what is the effect of the
#include, #define and #ifdef
... #endif directives.
Answer the following questions and check the answers with your lab partner before the lab session.
What is the difference between the directives
#include <file.h> y #include
"file.h"?
If program main.c includes the
file main.h, is the following command
correct?
$ gcc -o main main.c
What is the difference between the directive
#define SYMBOL and #define SYMBOL
10?
Suppose you need to have two versions of a program
that you wrote. The first version is used by you to detect errors
and the program prints on the screen all types of check
messages. The second version is for the customer and those messages
cannot appear. How would you achieve this with the
#ifdef directive?
Prepare your virtual machine to work with a command terminal and the compiler.
Edit the files main.c and
main.h. Additionally to the #ifdef directive,
the program uses the #ifndef directive that is simply the
negation of the previous one. Create two executable versions, one that
prints msg1 and not msg2, and another that
prints both messages.