Difference between revisions of "Cpp Coding Standards/HEADERS/IncGuards"

From Apache OpenOffice Wiki
Jump to: navigation, search
(moving from summary page to details)
 
 
Line 1: Line 1:
 
==== Internal Include Guards (IncGuards) ====
 
==== Internal Include Guards (IncGuards) ====
  
Internal include guards are good but '''don't''' use the external ones. They add a lot of noise for a non-existent benefit. Also, they add anwanted, and not always noted, dependencies, if for any reason the guarding define changes.
+
Internal include guards are good but '''don't''' use the external ones. They add a lot of noise for a non-existent benefit. Also, they add unwanted, and not always noted, dependencies, if for any reason the guarding define changes.
  
 
  // Foo.hxx
 
  // Foo.hxx
Line 21: Line 21:
 
  #include "Foo.hxx"
 
  #include "Foo.hxx"
 
  #include "Baz.hxx"
 
  #include "Baz.hxx"
 +
[[Category:Coding Standards]]

Latest revision as of 17:12, 14 December 2009

Internal Include Guards (IncGuards)

Internal include guards are good but don't use the external ones. They add a lot of noise for a non-existent benefit. Also, they add unwanted, and not always noted, dependencies, if for any reason the guarding define changes.

// Foo.hxx

// Yes, use internal include guards
#ifndef INCLUDED_FOO_HXX
#define INCLUDED_FOO_HXX

// No include guards here
#include "Superclass.hxx" 
...

#endif
// Bar.cxx

// No include guards here
#include "Bar.hxx"
#include "Foo.hxx"
#include "Baz.hxx"
Personal tools