使用“近”时编译器错误。作为变量名 [英] Compiler error when using "near" as a variable name
本文介绍了使用“近”时编译器错误。作为变量名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的代码中有一个非常奇怪的错误。我在C ++中创建了这个类:
I get a very weird error in my code. I created this class in C++:
class Tester{
float f;
Tester(float,float);
};
我实现了这样:
Tester::Tester(float near,float a){
this->f=near/a;
}
我收到以下错误:
..\src\Tester.cpp: In constructor 'Tester::Tester(float, float)':
..\src\Tester.cpp:4:14: error: expected primary-expression before '/' token
this->f=near/a;
^
>到其他错误消失。这不是一个大问题,当然,因为我可以重命名变量,但我只是好奇,如果有人知道原因。
when i rename near
to something else the error disappears. thats not a big deal of course because i can rename the variable, but i was just curious if someone of you knows the reason.
更新:
原因是 windef.h
的不合作。它包含在 windows.h
通过 wglext.h
。
The reason is the inlusion of windef.h
. it was included by windows.h
via wglext.h
.
推荐答案
看起来near在一些标题中被编译器定义为一个宏。通常这个宏与near指针一起使用。
It seems that near is defined as a macro by the compiler in some header. Usually this macro is used with "near" pointers.
这篇关于使用“近”时编译器错误。作为变量名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文