Problem with MSVS 2008 with gregorian

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

On Fri, 14 Nov 2008 16:20:31 +0100, Dan Smithers
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.
[...] Is there a workaround?
#define NOMINMAX Boris

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.
[snip] You could try putting a "#define NOMINMAX" before including the "windows.h" header. But beware that I'm not an expert, so it might not work, or cause something else to fail. -yzt

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
//#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

Dmitry Bufistov schrieb:
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
//#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?
if you don't need the MIN / MAX macro then you can define #define NOMINMAX regards Hansjörg
participants (5)
-
Boris
-
Dan Smithers
-
Dmitry Bufistov
-
Hansi
-
Yaser Zhian