2 /* Simple test of the SDL threading code and error handling */
9 #include "SDL_thread.h"
13 /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
14 static void quit(int rc)
20 int SDLCALL ThreadFunc(void *data)
22 /* Set the child thread error string */
23 SDL_SetError("Thread %s (%d) had a problem: %s",
24 (char *)data, SDL_ThreadID(), "nevermind");
26 printf("Thread '%s' is alive!\n", (char *)data);
29 printf("Child thread error string: %s\n", SDL_GetError());
33 int main(int argc, char *argv[])
37 /* Load the SDL library */
38 if ( SDL_Init(0) < 0 ) {
39 fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
43 /* Set the error value for the main thread */
44 SDL_SetError("No worries");
47 thread = SDL_CreateThread(ThreadFunc, "#1");
48 if ( thread == NULL ) {
49 fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError());
53 printf("Waiting for thread #1\n");
55 SDL_WaitThread(thread, NULL);
57 printf("Main thread error string: %s\n", SDL_GetError());