宏和成员函数冲突 [英] macro and member function conflict
问题描述
我有问题,std :: numeric_limits :: min()与windef.h中定义的min宏冲突。有没有办法解决这个冲突,而不需要定义min宏。
下面的链接提供了一些提示,但是我不能使用带有静态成员函数的括号。
I have problem that,std::numeric_limits::min() conflicts with the "min" macro defined in "windef.h". Is there any way to resolve this conflict without undefine the "min" macro. The link below gives some hints, however I couldn't manage to use parenthesis with a static member function.
提前感谢。
推荐答案
解决方法是使用圆括号: int max =(numeric_limits< int> :: max)();
The workaround is to use the parenthesis: int max = (numeric_limits<int>::max)();
$ c> windef.h ,不需要你 #undef max
(这可能有不良的副作用),没有必要 #define NONIMAX
。就像一个魅力!
It allows you to include the windef.h
, doesn't require you to #undef max
(which may have adverse side effects) and there is no need to #define NONIMAX
. Works like a charm!
这篇关于宏和成员函数冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!