4.13 Guarding against multiple inclusion of header files

Guarding against multiple inclusion of header files has a number of benefits.

Specifically, 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
Related reference
7.69 -g
Non-ConfidentialPDF file icon PDF versionARM DUI0375E
Copyright © 2007, 2008, 2011, 2012, 2014 ARM. All rights reserved.