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