rat de combat attention rongeur méchant! | Sinon j'arrive à ceci. Ca compile sans warnings et dans mon test ça marche, mais est-ce que c'est fiable et respecte le standard??
Code :
- #include <stdlib.h>
- #include <stdio.h>
- #include <stdarg.h>
- void debug_log_screen(char * str_fmt, ...) //prototype fixe
- {
- //juste pour test supposons int, int et on s'en fout de l'ordre d'exécution des paramètres de printf()
- va_list ap;
- va_start(ap, str_fmt);
- printf("%s %d %d\n", str_fmt, va_arg(ap, int), va_arg(ap, int));
- va_end(ap);
- }
- void debug_log(char* str_fmt, ...) //fonction à faire
- {
- va_list ap;
- va_start(ap, str_fmt);
- debug_log_screen(str_fmt, *ap);
- va_end(ap);
- }
- int main(void)
- {
- debug_log("test", 1, 2);
- return 0;
- }
|
|