Next: if ifdef ifndef Up: The C Preprocessor Previous: define undef

include

There are two slightly different forms. The first has the syntax:

#include "filename"

This is a means of notionally including one file in another. The compiler switches its attention to the included file and then returns to the one containing the include. The effect is that the compiler sees both as one long file, though of course the source files are not actually changed.

This is a valuable way of organizing #defines which are to be used across several source files What you do is put all of your #defines in a file, and then include that file in all source files needing those defines.

It is also used to include header files of shared declarations and this is in fact the only clean way of doing this.

The second syntax is, for example:

#include <stdio.h>

This is the same usage, but now the <> shows that the file is one of the system ones stored in a standard place.



Next: if ifdef ifndef Up: The C Preprocessor Previous: define undef


maspjw@
Tue Sep 27 15:29:34 BST 1994