Domanda

When I try to compile this:

#include <SDL/SDL.h>
#include "SDL_thread.h"
int main(void) {    
    SDL_Thread athread; 
    return 0;
}

with:

gcc SDL_Thread_test.c -o SDL_Thread_test `sdl2-config --cflags --libs` -lSDL

I get:

error: storage size of ‘athread’ isn’t known
  SDL_Thread athread;
             ^

Perhaps there is something else I need to #include?

È stato utile?

Soluzione

You cannot create a SDL_thread structure. The structure information is private and not known to the compiler.

SDL_Thread API only requires you to use a pointer to SDL_Thread which you can declare.

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

You will never need to operate with a structure directly.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top