2014-03-26 75 views
0

當我嘗試編譯此:SDL_Thread的存儲大小未知?

#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; 
      ^

也許還有別的東西,我需要#包括?

回答

2

您不能創建SDL_thread結構。結構信息是私有的,編譯器不知道。

SDL_Thread API只要求您使用指向SDL_Thread的指針,您可以聲明該指針。

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

您將永遠不需要直接操作結構。

+0

呃,愚蠢的錯誤。謝謝。 – Duovarious