C++:奇怪的错误“expectedinitializer before extern”在库 SDL_image.h 中
我目前正在尝试使用 SDL 和 Box2D 制作一个简单的游戏。不幸的是,我添加的用于制作角色射击项目的代码是如此错误,我什至无法开始计算错误。为了解决这个问题,我添加了一些代码来显示游戏中的一些调试信息。不幸的是,在处理完所有错误后,弹出了一个以前没有出现过的奇怪错误:
/usr/include/SDL/SDL_image.h|34|error: expected initializer before ‘extern’|
||=== Build finished: 1 errors, 0 warnings ===|
SDL_image.h 中导致此问题的代码是:
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
我不知道是什么原因导致此错误消息出现,或者如何解决此问题。我的代码上没有错误消息。我不认为这个库有什么问题,因为我做的其他游戏只编译文件。这是弹出的唯一错误。
I'm currently trying to make a simple game with SDL and Box2D. Unfortunately, the code I added to make the character shoot proyectiles is so buggy I can't even begin to count the errors. To deal with this I added some code to show some debug info in the game. Unfortunately, after dealing with all the errors a weird error that didn't appear before popped up:
/usr/include/SDL/SDL_image.h|34|error: expected initializer before ‘extern’|
||=== Build finished: 1 errors, 0 warnings ===|
The code in SDL_image.h that causes this is:
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
I have no idea what causes this error message to appear, or how to solve this. There are no error messages on my code. I don't think there's anything wrong with the library because other game I did compiles just file. This is the only error that pops up.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看一下在此之前包含的头文件的末尾。我的猜测是类定义后缺少
;
。Have a look at the end of the header files that are included before this one. My guess is that there's a missing
;
after a class definition.