Problem calling std::max

后端 未结 2 1041
[愿得一人]
[愿得一人] 2020-12-12 22:21

I compiled my bison-generated files in Visual Studio and got these errors:

...\\position.hh(83): error C2589: \'(\' : illegal token on right side of \

相关标签:
2条回答
  • 2020-12-12 23:05

    Define the NOMINMAX symbol at the top of your source, before you include any headers. Visual C++ defines min and max as macros somewhere in windows.h, and they interfere with your use of the corresponding standard functions.

    #define NOMINMAX
    
    0 讨论(0)
  • 2020-12-12 23:09

    You are probably including windows.h somewhere, which defines macros named max and min.

    You can #define NOMINMAX before including windows.h to prevent it from defining those macros, or you can prevent macro invocation by using an extra set of parentheses:

    column = (std::max)(1u, column + count);
    
    0 讨论(0)
提交回复
热议问题