...
Code Block |
---|
|
long maxValue;
int length;
|
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 |
---|
|
#ifndef _MY_HEADER_H_
#define _MY_HEADER_H_
/* contents of <my_header.h> */
#endif /* _MY_HEADER_H_ */
|
The compliant solution avoids using leading or trailing underscores in the name of the header guard.
Code Block |
---|
|
#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.
...