Boost logo

Boost :

From: Matthias Schabel (boost_at_[hidden])
Date: 2006-11-06 13:31:27


While fine-tuning my units code, I've run into something that's
puzzling to me. Here's a minimal example: if I try to compile this
program:

#include <iostream>

namespace boost {

namespace units {

typedef int time;
typedef double length;

} // namespace units

} // namespace boost

int main(void)
{
        using namespace boost::units;
        
        length x = 10;
        time t = 2;
        
        return 0;
}

I get an error : "'time' not declared in this scope". However, if I
fully qualify the namespace for "time", it compiles fine:

#include <iostream>

namespace boost {

namespace units {

typedef int time;
typedef double length;

} // namespace units

} // namespace boost

int main(void)
{
        using namespace boost::units;
        
        length x = 10;
        boost::units::time t = 2;
        
        return 0;
}

This is on Xcode 2.4 (gcc 4.0.1). I assume that there is a definition
of "time" somewhere in the standard headers that is polluting the
global namespace. Has anyone run into this before? Any suggestions?

Matthias


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