Cpp Coding Standards/HEADERS/IncGuards

From Apache OpenOffice Wiki
Jump to: navigation, search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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