【问题标题】:Storage size of SDL_Thread isn’t known?SDL_Thread 的存储大小未知?
【发布时间】:2014-03-26 04:18:45
【问题描述】:

当我尝试编译时:

#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 其他东西?

【问题讨论】:

    标签: c multithreading sdl sdl-2


    【解决方案1】:

    您不能创建 SDL_thread 结构。结构信息是私有的,编译器不知道。

    SDL_Thread API 只要求您使用指向您可以声明的 SDL_Thread 的指针。

    SDL_Thread* thread ;    //note the pointer
    thread = SDL_CreateThread(int (*fn)(void *), void *data);
    

    您永远不需要直接操作结构。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-07-24
      • 1970-01-01
      • 2022-07-08
      • 2019-06-30
      • 1970-01-01
      • 1970-01-01
      • 2013-04-15
      相关资源
      最近更新 更多