[Next] [Prev] [Up] [Top]

4.0 Source Code Files

Include Files


4.6.1 Protect against multiple inclusion (R)

Use the following lines in every header file to prevent problems from multiple inclusion:

#ifndef MYFILE_H

#define MYFILE_H

...

#endif

4.6.2 Protect against multiple preprocessing (R)

Use the following whenever including an interface file:

#ifndef MYFILE_H

#include "myfile.h"

#endif

This rule is not needed for systems which implement precompiled headers, like MSVC++ on the PC.

4.6.3 Do not insert absolute paths in include file names. (R)

Never insert absolute path information in the include file name, including system header files. This should be taken care of by compile-time switches.

#include "/a/b/c/bad.h" // bad!

#include "c:\\windows\\system\\stuff.h" // bad!

4.6.4 Header files should compile with no extra includes (R)

Header files should be self-contained with respect to supporting include files. That is, a give header file should always include enough support header files to compile without having the client include any other headers.

4.6.5 Alphebatize include files (R)

Insert include statements for system includes first, then application include files. Since application include files are "stand-alone", they should be arranged alphabetically in the implementaion files. Put any product-specific includes at the end of the list, alphabetized within a product scope.


No Title
[Next] [Prev] [Up] [Top]

Generated with CERN WebMaker

This site was grabbed using the TRIAL version of Grab-a-Site. This message does not appear on a licensed copy of Grab-a-Site.