macro and member function conflict

前端 未结 5 541
名媛妹妹
名媛妹妹 2020-12-05 18:05

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 \"mi

5条回答
  •  离开以前
    2020-12-05 18:29

    The workaround is to use the parenthesis: int max = (std::numeric_limits::max)();

    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 NOMINMAX. Works like a charm!

提交回复
热议问题