警告C4003:宏'max'的实际参数不足 - Visual Studio 2010 C ++ [英] warning C4003: not enough actual parameters for macro 'max' - Visual Studio 2010 C++
问题描述
在Visual Studio 2010 SP1上编译openFrameworks 007项目时,我有以下警告:
I have the following warnings while compiling an openFrameworks 007 project on Visual Studio 2010 SP1:
d:\pedro\development\videoflow\openframeworks\libs\openframeworks\types\ofcolor.h(127): warning C4003: not enough actual parameters for macro 'max'
d:\pedro\development\videoflow\openframeworks\libs\openframeworks\types\ofcolor.h(128): warning C4003: not enough actual parameters for macro 'max'
d:\pedro\development\videoflow\openframeworks\libs\openframeworks\graphics\ofpixels.h(150): warning C4003: not enough actual parameters for macro 'max'
d:\pedro\development\videoflow\openframeworks\libs\openframeworks\graphics\ofpixels.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() );
我尝试在预处理器上设置NOMINMAX,但由于openFrameworks也在onConstants.h中定义了NOMINMAX。
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.
我试图在受影响的openFrameworks文件中定义NOMINMAX,但它会导致相同的警告(实际上,如果我分析文件包括onColor.h和Pixel.h,它们最终包含Constants.h,因此应该定义NOMINMAX)。
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).
有关如何解决这个问题的任何想法?如果你不...最好是什么?这个警告或一系列警告已经定义了NOMINMAX?
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?
编辑:
错误我在谈论这些:警告C4003和错误C2589和C2059 on:x = std :: numeric_limits< int> :: max();
如果我试图重现一个干净的C ++项目的问题。但在我的openFrameworks项目,我只是得到警告。
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!!
推荐答案
添加 #undef max
相关文件的顶部。
这篇关于警告C4003:宏'max'的实际参数不足 - Visual Studio 2010 C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!