相关疑难解决方法(0)

警告C4003和错误C2589和C2059 on:x = std :: numeric_limits <int> :: max();

这行在小型测试程序中正常工作,但在我想要它的程序中,我得到以下编译器投诉:

#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 : '::'
Run Code Online (Sandbox Code Playgroud)

我得到了相同的结果:

#include <limits>
using namespace std;

x = numeric_limits<int>::max();
Run Code Online (Sandbox Code Playgroud)

为什么它将max视为宏max(a,b); ?

c++ max visual-c++ numeric-limits

56
推荐指数
3
解决办法
2万
查看次数

无法调用std :: max,因为minwindef.h定义了"max"

我怎么去实际调用std :: max?代码将无法在visual studio 2013中编译,因为它将"max"作为宏.

std::max( ... );
Run Code Online (Sandbox Code Playgroud)

预期"std ::"之后的标识符.

c++ macros std

11
推荐指数
1
解决办法
6453
查看次数

标签 统计

c++ ×2

macros ×1

max ×1

numeric-limits ×1

std ×1

visual-c++ ×1