參考資訊:
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) { printf("%s: %d\n", __func__, interval); return 0; } int main(int argc, char **argv) { SDL_Init(SDL_INIT_TIMER); SDL_SetTimer(1000, mytimer); SDL_Delay(3000); SDL_SetTimer(0, NULL); SDL_Quit(); return 0; }
編譯、執行
$ gcc main.c -o main -lSDL -I/usr/include/SDL $ ./main mytimer: 1000