[Xapian-discuss] Compiling problem

Olly Betts olly at survex.com
Thu Dec 30 15:31:40 GMT 2004


On Thu, Dec 30, 2004 at 10:29:14AM +0100, Penz, Bernhard wrote:
> I checked with my Stoustrup, and after a bit of guessing I found the
> grammar rule for that thing. So it is valid C++ syntax, but Microsofts
> compiler doesn't handle this correct. I am still wondering how this
> should work anyway. When btree.h is included several times, how does the
> compiler at compile-time know that it should create the one instance of
> max_key_len that is needed? There must be some magic involved at linking
> time that the Microsoft compiler does not do....

Since it's const and initialised to a constant value at compile time, it
doesn't need a "variable slot" anywhere - it can just be substituted
whenever it's used.  It's effectively just a type-safe #define.

> Well, that would work, too. But in that case things would have to be
> initialized in the constructor:

Ah yes.  Hmm.  I'd really rather not force this value to be a static
member initialised elsewhere as it makes the source a little less clear,
and the generated code a little less good.

I guess we can just pull it out to be a const outside the class in the
header.

Cheers,
    Olly



More information about the Xapian-discuss mailing list