问题描述
我在 Visual Studio 中编译了我的野牛生成的文件,并得到了这些错误:
I compiled my bison-generated files in Visual Studio and got these errors:
...position.hh(83): error C2589: '(' : '::'右侧的非法标记
...position.hh(83):错误 C2059:语法错误:'::'
...position.hh(83): error C2589: '(' : '::'右侧的非法标记
...position.hh(83):错误 C2059:语法错误:'::'
...position.hh(83): error C2589: '(' : illegal token on right side of '::'
...position.hh(83): error C2059: syntax error : '::'
...position.hh(83): error C2589: '(' : illegal token on right side of '::'
...position.hh(83): error C2059: syntax error : '::'
对应的代码为:
我认为问题在于 std::max;如果我将 std::max 更改为等效代码,那么就没有问题了,但是有没有更好的解决方案而不是更改生成的代码?
I think the problem is with std::max; if I change std::max to equivalent code then there is no problem anymore, but is there a better solution instead of changing the generated code?
这是我写的野牛文件:
推荐答案
你可能在某处包含了 windows.h
,它定义了名为 max
和 min 的宏
.
You are probably including windows.h
somewhere, which defines macros named max
and min
.
您可以在包含 windows.h
之前#define NOMINMAX
以防止它定义这些宏,或者您可以使用一组额外的括号来防止宏调用:
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:
这篇关于调用 std::max 时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!