C++ SDL Mixer Mix_Music:不允许不完整的类型
每当我尝试创建 Mix_Music 实例时,都会收到此错误:“不允许使用不完整的类型”。
但是,在调用 Mix_LoadMUS(file); 之前,我需要获取指针 music 的地址。
代码:
Mix_Music *music;
/* I need the memory address here */
music = Mix_LoadMUS(file);
我该怎么做?
whenever I try to create Mix_Music instance, I get this error: "incomplete type is not allowed".
However, I need to get the address of the pointer music before calling Mix_LoadMUS(file);
Code:
Mix_Music *music;
/* I need the memory address here */
music = Mix_LoadMUS(file);
How do I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不完整类型
#include "SDL_mixer.h" 应该没问题1,2。
如果没有 SDL 包含来告诉编译器这些 SDL 引用(Mix_Musi、Mix_LoadMUS 等)也引用了什么,编译器就无法编译与 SDL 相关的代码。请参阅 kekkai.org/roger3 上的 SDL_Mixer 教程,它有一个完整的示例。
1 SDL 包含文件
2 Mix_LOadMUS
3 带有完整示例的 SDL 教程
--
更新:使用音乐数组Items
这是一个示例,说明如何从线程代码内或在词法上与分配的任何地方访问指向 Mix_ Music 的特定指针。指针变量。实际的实现可能需要使用动态数组分配,并且需要添加对文件未找到或加载失败等的错误处理。
MEnt.h 初始化和线程模块的通用 iinclude 文件:
程序初始化:
在线程的代码,包括:
Incomplete Type
#include "SDL_mixer.h" and it should be fine1,2.
The compiler is not capable of compiling SDL-related code without the SDL includes to tell it what those SDL refernces (Mix_Musi, Mix_LoadMUS, etc) refer too. See the SDL_Mixer Tutorial at kekkai.org/roger3 It has a complete example.
1 SDL Include file
2 Mix_LOadMUS
3 SDL Tutorial with complete example
--
Update: Using an Array of Music Items
This is an example of how to access a particular pointer to Mix_ Music from within a thread's code, or in any place lexically separate from the allocation of the pointer variable. An actual implementation may want to use dynamic array allocation and needs to add error handling for file-not-found or failed-to-load, etc.
MEnt.h A common iclude file for the initilization and thread modules:
Program initialization:
In the thread's code,include: