SDL_Surface 的外部编译错误

发布于 2024-07-17 08:44:35 字数 425 浏览 6 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

睡美人的小仙女 2024-07-24 08:44:35

这是一个疯狂的猜测,因为我没有太多工作可做。 在 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 that extern?

清秋悲枫 2024-07-24 08:44:35

您似乎缺少 SDL_Surface 的定义。 确保#include定义了SDL_Surface的正确头文件。 或者,如果您实际上并未使用 screen 变量(即您未访问其任何字段),则可以使用不完整类型来声明它,如下所示:

extern struct SDL_Surface *screen;

It looks like you're missing the definition of SDL_Surface. Make sure to #include the proper header file in which SDL_Surface is defined. Alternatively, if you're not actually using the screen variable (i.e. you're not accessing any of its fields), you can declare it using an incomplete type as so:

extern struct SDL_Surface *screen;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文