Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Added an example.

...

Code Block
bgColor#ccccff

long maxValue;
int length;

Noncompliant Code Example (Header Guard)

A common but non-compliant practice is to choose a reserved name for the name of a macro used in a preprocessor conditional guarding against multiple inclusion of a header file. See also PRE06-C. Enclose header files in an inclusion guard.

Code Block
bgColor#FFCCCC

#ifndef _MY_HEADER_H_
#define _MY_HEADER_H_

/* contents of <my_header.h> */

#endif /* _MY_HEADER_H_ */

Compliant Solution (Header Guard)

The compliant solution avoids using leading or trailing underscores in the name of the header guard.

Code Block
bgColor#ccccff

#ifndef MY_HEADER_H
#define MY_HEADER_H

/* contents of <my_header.h> */

#endif /* MY_HEADER_H */

Noncompliant Code Example

In this example, a variable beginning with an underscore is defined with implicit global scope.

...