Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
341 views
in Technique[技术] by (71.8m points)

warning C4003: not enough actual parameters for macro 'max' - Visual Studio 2010 C++

I have the following warnings while compiling an openFrameworks 007 project on Visual Studio 2010 SP1:

d:pedrodevelopmentvideoflowopenframeworkslibsopenframeworksypesofcolor.h(127): warning C4003: not enough actual parameters for macro 'max'
d:pedrodevelopmentvideoflowopenframeworkslibsopenframeworksypesofcolor.h(128): warning C4003: not enough actual parameters for macro 'max'
d:pedrodevelopmentvideoflowopenframeworkslibsopenframeworksgraphicsofpixels.h(150): warning C4003: not enough actual parameters for macro 'max'
d:pedrodevelopmentvideoflowopenframeworkslibsopenframeworksgraphicsofpixels.h(151): warning C4003: not enough actual parameters for macro 'max'

From what I could tell this warnings are usually followed by errors but in my case everything works ok. The affected code is below:

const float srcMax = ( (sizeof(SrcType) == sizeof(float) ) ? 1.f : numeric_limits<SrcType>::max() );
const float dstMax = ( (sizeof(PixelType) == sizeof(float) ) ? 1.f : numeric_limits<PixelType>::max() );

I tried to set NOMINMAX on the preprocessor but since openFrameworks also defines NOMINMAX on ofConstants.h I get a bunch of warnings that NOMINMAX is already defined.

I have tried to define NOMINMAX on the affected openFrameworks files but it results on the same warning (in fact if I analyze the files included on ofColor.h and ofPixel.h they end up including ofConstants.h so NOMINMAX should be defined).

Any idea on how to solve this? If you don't... what would be best? This warnings or a bunch of warnings that NOMINMAX is already defined?

EDIT:

BTW when I talked about errors I was talking about these: warning C4003 and errors C2589 and C2059 on: x = std::numeric_limits<int>::max();

I get this (the warning plus 2 errors) if I try to reproduce the problem on a clean C++ project. But on my openFrameworks project I just get the warnings. That's why I get confused!!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You are not the first to be bitten by these ancient macros. They can't remove them, that would break old code. So they came up with another macro to remove the sting. Make it look like this:

#ifndef NOMINMAX
# define NOMINMAX
#endif
#include <windows.h>
// Rest of your #includes here
//...

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...