gpt4 book ai didi

c - SDL_Thread 的存储大小未知?

转载 作者:太空宇宙 更新时间:2023-11-04 02:50:30 29 4
gpt4 key购买 nike

当我尝试编译时:

#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/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com