Page 1 of 1

Macro defintion of max?

Posted: Fri Feb 17, 2006 13:11
by pokemoen
CEGUIBase.h

Code: Select all

00063 // Detect macros for min / max and undefine (with a warning where possible)
00064 #if defined(max)
00065 #   if defined(_MSC_VER)
00066 #       pragma message("Macro defintion of max detected - undefining")
00067 #   elif defined (__GNUC__)
00068 #       warning ("Macro defintion of max detected - undefining")
00069 #   endif
00070 #   undef max
00071 #endif
00072 #if defined(min)
00073 #   if defined(_MSC_VER)
00074 #       pragma message("Macro defintion of min detected - undefining")
00075 #   elif defined (__GNUC__)
00076 #       warning ("Macro defintion of min detected - undefining")
00077 #   endif
00078 #   undef min
00079 #endif


1st: What is a "defintion"? ;)
2nd: Why am I getting this message exactly? I don't know when this check was added, but I didn't get the warnings before.. What could I have changed to start defining min and max?

Just curious..

TIA!
Alex

Posted: Fri Feb 17, 2006 14:59
by Dalfy
a definition is a preprocessor command of the form

Code: Select all

#define var value.


The preprocessor will make use of this definition and substitute every where in the code var by value. There is possibly to kind of definition:
macro and constant.

For a detailed description of the preprocessor you might have a look on any book on C or look foward cpp on google.

Posted: Fri Feb 17, 2006 21:55
by pokemoen
I know what a definition is, read carefully ;)

Posted: Sat Feb 18, 2006 01:45
by lindquist
hehe. a little type we have :P

You're seeing this because of some M$ stupidity there min and max are defined as macros.

min, max are so common names that this is truely dumb. therefore cegui removes these definitions if found.

HTH

[edit] I have fixed this typo in CVS head btw [/edit]

Posted: Sun Feb 19, 2006 17:47
by pokemoen
Okay, cool, thanks :)

Re: Macro defintion of max?

Posted: Thu Mar 16, 2006 14:19
by baxissimo
pokemoen wrote:2nd: Why am I getting this message exactly? I don't know when this check was added, but I didn't get the warnings before.. What could I have changed to start defining min and max?


It might have also started to appear because either you or CEGUI changed the order in which some headers are included. If Microsoft's header gets included after CEGUI then you won't get the message. If before, then you will.

Re: Macro defintion of max?

Posted: Sat May 27, 2006 13:47
by muhkuh
baxissimo wrote:
pokemoen wrote:2nd: Why am I getting this message exactly? I don't know when this check was added, but I didn't get the warnings before.. What could I have changed to start defining min and max?


It might have also started to appear because either you or CEGUI changed the order in which some headers are included. If Microsoft's header gets included after CEGUI then you won't get the message. If before, then you will.


This happened serveral times for me so I put a NOMINMAX preprocessor definition in every visual studio project of CEGUI. May be this could be applied to svn trunk so it's more robust when the order of included headers changes?