Boost logo

Boost :

From: Valentin Bonnard (Bonnard.V_at_[hidden])
Date: 1999-08-31 12:50:54


Greg Colvin wrote:
>
> From: Valentin Bonnard <Bonnard.V_at_[hidden]>
> > ...
> > /users/bonnard/debug_mode.hpp:
> > > extern const bool debug_mode = true
> >
> > /users/bonnard/debug_mode.cpp:
> > > #include "debug_mode.hpp"
> > > const bool debug_mode;
>
> I think that, despite the extern, the declaration in debug_mode.hpp is a
> definition, because of the initializer:
>
> 3.1 Declarations and definitions [basic.def]

> 2 A declaration is a definition unless it declares a function without
> specifying the function's body (_dcl.fct.def_), it contains the extern
> specifier (_dcl.stc_) or a linkage-specification1) (_dcl.link_) and
> neither an initializer nor a function-body, it declares a static data
> member in a class declaration (_class.static_), it is a class name
> declaration (_class.name_), or it is a typedef declaration (_dcl.type-
> def_), a using-declaration (_namespace.udecl_), or a using-directive
> (_namespace.udir_).

I missed the ``and neither'' part because it looked like this:

 -2- A declaration is a definition unless it declares a function without
specifying the function's body (dcl.fct.def), it
contains the extern specifier (dcl.stc) or a linkage-specification*

     [Footnote: Appearing inside the braced-enclosed declaration-seq in
a linkage-specification does not affect
     whether a declaration is a definition. --- end foonote]

(dcl.link) and neither ...

I didn't read below the footnote (I thouth that the paragraph was
finished).

What about:

struct debug { static const bool mode = true; };

in this case it is not a definition.

(Sorry for the confusion.)

-- 
Valentin Bonnard

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk