[C++] std::numeric_limits::max() error: '(': illegal token on right side of '::'

来源:互联网 发布:阿里域名服务器地址 编辑:程序博客网 时间:2024/05/23 15:47

#include <limits> 
 
x
= std::numeric_limits<int>::max(); 
 
c
:/.../x.cpp(192) : warning C4003: not enough actual parameters for macro 'max' 
c
:/.../x.cpp(192) : error C2589: '(' : illegal token on right side of '::' 
c
:/.../x.cpp(192) : error C2059: syntax error : '::' 

错误原因:

      包含的另一个头文件中包含了 max() 的宏定义。

 

解决方法:

添加代码:

 

#undef max

 

相关讨论: