AntTweakBar 回调抛出“';'方法前的预期“错误
AntTweakBar callbacks throwing " ';' expected" error before method
按照教程创建基本粒子系统后,我开始实施 AntTweakBar 以获得基本 UI。一切顺利,一切顺利。但是一旦我开始添加回调函数,它就开始变得有点混乱,声称它在方法定义的中间抛出了这个:
Intellisense: expected a ';'
有问题的方法是:
void GLFWCALL OnMouseRight(int glfwButton, int glfwAction)
{
if( !TwEventMouseButtonGLFW(glfwButton, glfwAction) ) // Send event to AntTweakBar
{
if(glfwButton == GLFW_MOUSE_BUTTON_RIGHT)
computeMatricesFromInputs();
else
// Event has not been handled by AntTweakBar
// Do something if needed.
}
}
错误显然出现在名称 OnMouseRight
和后面的括号之间。我如何摆脱这个错误?我正在使用 C++ 在 OpenGL(使用 GLFW 和 GLEW)中进行编码,并且我一直在按照此 page on the AntTweakBar site 上的步骤进行操作。我已经查阅了大部分 GLFW 文档,但没有找到太多。任何帮助表示赞赏。
else
后缺少语句导致错误:
if(glfwButton == GLFW_MOUSE_BUTTON_RIGHT)
computeMatricesFromInputs();
else
// ^ no statement here
您可以按照 Intellisense 的建议添加分号或空的复合语句 {}
:
if(glfwButton == GLFW_MOUSE_BUTTON_RIGHT) {
computeMatricesFromInputs();
} else {
// Event has not been handled by AntTweakBar
// Do something if needed.
}
是的,经过一夜的工作解决这个问题并再次浏览 GLFW 的文档后,我注意到问题出在宏 GLFWCALL
上。 C++ 本身将其视为一种方法,因此忽略了实际的方法。 GLFW 的文档解释了原因:
The GLFWCALL
macro, which made callback functions use __stdcall
on Windows, has been removed. GLFW is written in C, not Pascal. Removing this macro means there's one less thing for users of GLFW to remember, i.e. the requirement to mark all callback functions with GLFWCALL
. It also simplifies the creation of DLLs
and DLL
link libraries, as there's no need to explicitly disable @n
entry point suffixes.
删除 GLFWCALL
并遵循@vitaut 的建议后,我的程序现在可以正确处理鼠标右键输入。
按照教程创建基本粒子系统后,我开始实施 AntTweakBar 以获得基本 UI。一切顺利,一切顺利。但是一旦我开始添加回调函数,它就开始变得有点混乱,声称它在方法定义的中间抛出了这个:
Intellisense: expected a ';'
有问题的方法是:
void GLFWCALL OnMouseRight(int glfwButton, int glfwAction)
{
if( !TwEventMouseButtonGLFW(glfwButton, glfwAction) ) // Send event to AntTweakBar
{
if(glfwButton == GLFW_MOUSE_BUTTON_RIGHT)
computeMatricesFromInputs();
else
// Event has not been handled by AntTweakBar
// Do something if needed.
}
}
错误显然出现在名称 OnMouseRight
和后面的括号之间。我如何摆脱这个错误?我正在使用 C++ 在 OpenGL(使用 GLFW 和 GLEW)中进行编码,并且我一直在按照此 page on the AntTweakBar site 上的步骤进行操作。我已经查阅了大部分 GLFW 文档,但没有找到太多。任何帮助表示赞赏。
else
后缺少语句导致错误:
if(glfwButton == GLFW_MOUSE_BUTTON_RIGHT)
computeMatricesFromInputs();
else
// ^ no statement here
您可以按照 Intellisense 的建议添加分号或空的复合语句 {}
:
if(glfwButton == GLFW_MOUSE_BUTTON_RIGHT) {
computeMatricesFromInputs();
} else {
// Event has not been handled by AntTweakBar
// Do something if needed.
}
是的,经过一夜的工作解决这个问题并再次浏览 GLFW 的文档后,我注意到问题出在宏 GLFWCALL
上。 C++ 本身将其视为一种方法,因此忽略了实际的方法。 GLFW 的文档解释了原因:
The
GLFWCALL
macro, which made callback functions use__stdcall
on Windows, has been removed. GLFW is written in C, not Pascal. Removing this macro means there's one less thing for users of GLFW to remember, i.e. the requirement to mark all callback functions withGLFWCALL
. It also simplifies the creation ofDLLs
andDLL
link libraries, as there's no need to explicitly disable@n
entry point suffixes.
删除 GLFWCALL
并遵循@vitaut 的建议后,我的程序现在可以正确处理鼠标右键输入。