当我尝试编译时:
#include <SDL/SDL.h>
#include "SDL_thread.h"
int main(void) {
SDL_Thread athread;
return 0;
}
与:
gcc SDL_Thread_test.c -o SDL_Thread_test `sdl2-config --cflags --libs` -lSDL
我得到:
error: storage size of ‘athread’ isn’t known
SDL_Thread athread;
^
也许我还需要#include 其他东西?
最佳答案
您不能创建 SDL_thread 结构。结构信息是私有(private)的,编译器不知道。
SDL_Thread API 只需要您使用指向您可以声明的 SDL_Thread 的指针。
SDL_Thread* thread ; //note the pointer
thread = SDL_CreateThread(int (*fn)(void *), void *data);
您永远不需要直接对结构进行操作。
关于c - SDL_Thread 的存储大小未知?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22651389/