[BloodyMess154] cannot recognize NxOgre::Real2 with MFC

kaneyxt

01-06-2009 09:49:25

I try to create a NxOgre window in MFC project, but get a compiling error. Seems system cannot recognize NxOgre::Real2.
The error message is as follows:
1>NeedleController.cpp
1>f:\project\bloodymess\sdk\nxogrerealvectors.h(91) : warning C4003: not enough actual parameters for macro 'min'
1>f:\project\bloodymess\sdk\nxogrerealvectors.h(91) : error C2226: syntax error : unexpected type 'NxOgre::Real2'
1>f:\project\bloodymess\sdk\nxogrerealvectors.h(91) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body
1>f:\project\bloodymess\sdk\nxogrerealvectors.h(95) : error C2143: syntax error : missing ')' before '}'
1>f:\project\bloodymess\sdk\nxogrerealvectors.h(95) : error C2143: syntax error : missing '}' before ')'
1>f:\project\bloodymess\sdk\nxogrerealvectors.h(95) : error C2059: syntax error : ')'
1>f:\project\bloodymess\sdk\nxogrerealvectors.h(95) : error C2143: syntax error : missing ';' before '}'
1>f:\project\bloodymess\sdk\nxogrerealvectors.h(95) : error C2238: unexpected token(s) preceding ';'
1>f:\project\bloodymess\sdk\nxogrerealvectors.h(97) : error C2628: 'NxOgre::Real2' followed by 'void' is illegal (did you forget a ';'?)
1>f:\project\bloodymess\sdk\nxogrerealvectors.h(97) : warning C4003: not enough actual parameters for macro 'max'
1>f:\project\bloodymess\sdk\nxogrerealvectors.h(97) : fatal error C1903: unable to recover from previous error(s); stopping compilation

If I do not use MFC project, this problem will not happen. I compare MFC project with others, the only difference is: in MFC project, I have to include "stdafx.h" header file. Does this file cause the compiling error?
Do I miss something? Such as the namespace definination or environment setting? I would really appreciative if someone can help me figure this out. Thanks!

betajaen

01-06-2009 09:59:12

You have to define #NOMINMAX somewhere before you include your windows header.

kaneyxt

01-06-2009 10:20:04

You have to define #NOMINMAX somewhere before you include your windows header.

Just try it out, but still meet the compiling error...
Any other comments? Thanks very much!

betajaen

01-06-2009 11:22:51

It's Windows/Microsoft defining min and max macros, it's a common problem.

The NOMINMAX define should stop them being defined. Just make sure it goes like this.

#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#include <windows.h>

kaneyxt

01-06-2009 11:56:24

I try to put "#NOMINMAX " to the top of stdAfx.h, then this problem goes away...
Thanks, man! :D

kaneyxt

22-07-2009 04:43:34

Hey, man, I get conflict while using NxOgre with GDI+, it is still the #NOMINMAX problem.
As we discussed here, I have to define #NOMINMAX to get NxOgre compiled. But when I use GDI+, it requires the min/max define of windows. If I use #NOMINMAX, I will get compiling errors in GDI+'s header files.
Is it possible to solve this problem in another way, so I can use NxOgre and GDI+ at the same time? Thanks!