You copied the Doc URL to your clipboard.

Guarding against multiple inclusion of header files

Guarding against multiple inclusion of header files:

  • improves compilation time

  • reduces the size of object files generated using the -g compiler command-line option, which can speed up link time

  • avoids compilation errors that arise from including the same code multiple times.

For example:

/* foo.h */
#ifndef FOO_H
#define FOO_H 1
...
#endif

/* bar.c */
#ifndef FOO_H
#include "foo.h"
#endif

See also

Reference

Compiler Reference:

Was this page helpful? Yes No