-Pio: Include Files Only Once

Group

INPUT

Scope

Compilation Unit

Syntax
  -Pio 
  
Arguments

None

Default

None

Defines

None

Pragmas

None

Description

Includes every header file only once. Whenever the compiler reaches an #include directive, the compiler checks the named file against the files already included. If the file has already been read, the compiler ignores the #include directive. It is common practice to protect header files from multiple inclusion by conditional compilation, as shown below:

  /* Header file myfile.h */

  
  #ifndef _MY_FILE_H_

  
  #define _MY_FILE_H_

  
  /* .... content .... */

  
  #endif /* _MY_FILE_H_ */

  

When #ifndef and #define directives are issued, the Compiler reads header file content only once even when the header file is included several times. This solves many problems as C-language protocol does not allow you to define structures (such as enums or typedefs) more than once.

Using this option to protect all header files can safely accelerate compilation.

Do not use this option when a header file must be included twice, for example, the file contains macros which are set differently at different inclusion times. In those instances, use #pragma ONCE: Include Once to accelerate the inclusion of safe header files which do not contain macros of that nature.

Example
  -Pio 
  
See also

#pragma ONCE: Include Once