Boost logo

Boost :

From: Eric Woodruff (Eric.Woodruff_at_[hidden])
Date: 2002-08-27 14:25:31

True, but I fail to see how co-dependent headers is ever the correct way to
implement something.

----- Original Message -----
From: David Bergman
Newsgroups: gmane.comp.lib.boost.devel
Sent: Tuesday, 2002:August:27 15:15
Subject: RE: #ifndef paradigm


What about a mutually recursive system, w.r.t. prepocessor file
inclusion? I.e, what about


#include "code2.hpp"

class code1 {
code1(code2* other) {}
int var;


#include "code1.hpp"

class code2 {
code2() { };
int var;


You need to #define the token before entering this mutually recursive


-----Original Message-----
From: boost-bounces_at_[hidden]
[mailto:boost-bounces_at_[hidden]] On Behalf Of Eric Woodruff
Sent: Tuesday, August 27, 2002 2:59 PM
To: boost
Subject: [boost] #ifndef paradigm

Often, when one wants to make sure a header is included only once, s/he
uses the paradigm:

#ifndef HEADER_NAME_H__
#define HEADER_NAME_H__

// code here...

#endif // HEADER_NAME_H__ -- this comment is to make it clear what the
endif is for

It is better to remove the duality of the comment at the end, by
switching to this paradigm:

#ifndef HEADER_NAME_H__

// code here...

#define HEADER_NAME_H__

When maintiaining a file -- renaming it -- with the comment, one has to
make sure the comment is also updated. This alternative removes the
comment because it is superfluous, and the compiler will help you if you
forget to change the #define at the end.

Unsubscribe & other changes:

Unsubscribe & other changes:

Boost list run by bdawes at, gregod at, cpdaniel at, john at