SDL_Surface 的外部编译错误
我在 Code::Block
中遇到 SDL_Surface
变量的编译错误。 奇怪的是,这是我第一次收到这种错误,因为我以前使用过这行代码并且运行得很好。
导致此问题的代码示例行之一(具有相同问题的代码行之一)是:
extern SDL_Surface *screen;
产生的错误是这样的:
expected init-declarator before "extern"|
expected `,' or `;' before "extern"|
||=== Build finished: 2 errors, 0 warnings ===|
我试图理解该错误,但我无法说出它是什么。 有谁知道可能出了什么问题?
I've been getting a compile error in Code::Block
for an SDL_Surface
variable. Strangely enough, this is the first time I have received this kind of error, as I have used this line of code previously and it has worked fine.
One (of several with the same problem) sample line of code that causes this problem is:
extern SDL_Surface *screen;
The resulting error is this:
expected init-declarator before "extern"|
expected `,' or `;' before "extern"|
||=== Build finished: 2 errors, 0 warnings ===|
I tried to understand the error, but I can not tell what it is. Does anyone know what might be wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个疯狂的猜测,因为我没有太多工作可做。 在
extern
之前,您是否拥有SDL_Surface
所需的所有标头?It's a wild guess since I don't have much to work with. Do you have all the headers required for
SDL_Surface
before thatextern
?您似乎缺少
SDL_Surface
的定义。 确保#include
定义了SDL_Surface
的正确头文件。 或者,如果您实际上并未使用 screen 变量(即您未访问其任何字段),则可以使用不完整类型来声明它,如下所示:It looks like you're missing the definition of
SDL_Surface
. Make sure to#include
the proper header file in whichSDL_Surface
is defined. Alternatively, if you're not actually using thescreen
variable (i.e. you're not accessing any of its fields), you can declare it using an incomplete type as so: