c - SDL_Thread 的存储大小未知?

标签 c multithreading sdl sdl-2

当我尝试编译时:

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

相关文章:

c++ - char数组的pid_t的初始值是什么?

c - 如何用 curl 做 keepalive http 请求?

java - 静态方法和静态 block 之间的线程安全

android - 如何在android中设置循环延迟?

interop - 与 C 版本 SDL2 链接时对 D 隐藏控制台

c++ - 程序在 SDL 中立即关闭

CGFX 着色器多次输出垂直数据

c - char* 数组以及如何为每个数组分配内存

c# - 更改另一个线程中使用的实例变量

windows - Haskell:无法在 Windows 上安装 SDL-0.6.2