宏和成员函数冲突 [英] macro and member function conflict

查看:239
本文介绍了宏和成员函数冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题,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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆