From 83d38847084605a0ec0e405573322680975b4897 Mon Sep 17 00:00:00 2001 From: levine Date: Thu, 15 Oct 1998 03:17:13 +0000 Subject: added guideline for protection of header files against multiple inclusion --- docs/ACE-guidelines.html | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/ACE-guidelines.html b/docs/ACE-guidelines.html index 52c5e0cc96f..cfe40056943 100644 --- a/docs/ACE-guidelines.html +++ b/docs/ACE-guidelines.html @@ -149,6 +149,23 @@ bgcolor="#ffffff"> const ASYS_TCHAR *net_if, #endif /* ! ACE_PSOS */

+ +

  • Protect header files against multiple inclusion with this + construct: +
    +        #ifndef FOO_H
    +        #define FOO_H
    +
    +        [contents of header file]
    +
    +        #endif /* FOO_H */
    +        

    + + This exact construct (note the #ifndef) + is optimized by many compilers such they only open the + file once per compilation unit. No code + can appear after the final #endif for the + optimization to be effective and correct.

  • C++ Syntax and Constructs

    -- cgit v1.2.1