今天编译工程时候,出现两个警告:
Compiling...
algorithm.cpp
d:vc6.0includevalarray(104) : warning C4003: not enough actualparameters for macro 'min'
d:vc6.0includevalarray(110) : warning C4003: not enough actualparameters for macro 'max'
结果就导致了下面的错误::
d:vc6.0includevalarray(104) : error C2059: syntax error :'function-style cast'
d:vc6.0includevalarray(167) : see reference to class templateinstantiation 'std::valarray<_Ty>'being compiled
d:vc6.0includevalarray(104) : error C2334: unexpected token(s)preceding ':'; skipping apparent function body
d:vc6.0i ncludevalarray(167) : see reference to class templateinstantiation 'std::valarray<_Ty>'being compiled
d:vc6.0includevalarray(109) : error C2143: syntax error :missing ')' before '}'
d:vc6.0includevalarray(167) : see reference to class templateinstantiation 'std::valarray<_Ty>'being compiled
d:vc6.0includevalarray(109) : error C2059: syntax error :')'
d:vc6.0includevalarray(167) : see reference to class templateinstantiation 'std::valarray<_Ty>'being compiled
d:vc6.0includevalarray(109) : error C2143: syntax error :missing ';' before '}'
d:vc6.0includevalarray(167) : see reference to class templateinstantiation 'std::valarray<_Ty>'being compiled
d:vc6.0includevalarray(109) : error C2238: unexpected token(s)preceding ';'
经网上求教,在十步的博客中找到了很好的解决办法,如下:
分析:not enough actual parameters for macro'min',说明它还是调用的vc自带的min()和max();
进入vc里面的min()函数,往上找,找到#ifndefNOMINMAX这个宏
故我们可以在程序中屏蔽掉这个宏,vc的min()和max()就不会被调用,也不会抱错,不过此程序就不能再用min()max()。
屏蔽方法:projiectà settingsàC/C++, 在preprocessor definitions 中加入NOMINMAX 即可。
此处提供解决此类方法的思路
谢谢十步~~