參考資訊:
https://www.libsdl.org/release/SDL-1.2.15/docs/html/index.html
main.c
#include <stdio.h> #include <stdlib.h> #include <SDL.h> #include <SDL_timer.h> Uint32 mytimer(Uint32 interval, void *param) { printf("%s: 0x%x\n", __func__, param); return 0; } int main(int argc, char **argv) { SDL_Init(SDL_INIT_TIMER); SDL_TimerID myid = SDL_AddTimer(1000, mytimer, (void*)0xdeadbeef); SDL_Delay(3000); SDL_RemoveTimer(myid); SDL_Quit(); return 0; }
編譯、執行
$ gcc main.c -o main -lSDL -I/usr/include/SDL $ ./main mytimer: 0xdeadbeef