Boost logo

Boost Users :

Subject: Re: [Boost-users] Problem with MSVS 2008 with gregorian
From: Dmitry Bufistov (dmitry_at_[hidden])
Date: 2008-11-28 09:36:35


Dan Smithers wrote:
> Hi I have a problem building under studio 2008. It appears that
>
> #define max(a,b) ...
>
> collides with the member function greg_month::max() and won't compile
> complaining that not enough arguments are provided.
>
> I have stripped the code down
>
> test.cpp
>
> #include <windows.h>
>
> //#undef max
> #include "boost/date_time/gregorian/gregorian.hpp"
>
> void foo()
> {
> boost::gregorian::greg_month::max();
> }
>
> If I put #undef max before including gregorian.h then it compiles.
>
> Without I get the errors
>
> warning C4003: not enough actual parameters for macro 'max'
> error C2589: '(' illegal token on right side of '::'
> error C2143: syntax error : missing ';' before '::'
>
> Has anyone seen this before?
>
> Is there a workaround?
>

Hi Dan,

I usually fight against this problem like this:
void foo()
{
          (boost::gregorian::greg_month::max)();
}

Regards,
Dmitry


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net