Bonjour,
Pour un projet où il faut écrire sur un lcd, j'ai écrit une fonction putchar et une fonction print qui appelle ce putchar.
car comme la macro est remplacée par plusieurs lignes de code, il y a bien évidemment une erreur avant le else. J'ai bien essayé de mettre des accolades dans la macro, mais ça ne marche pas.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 #ifdef printf #undef printf #endif #define printf(format, args ...) sprintf(VOSC_PrintBuf,format, ## args); print(VOSC_PrintBuf) #ifdef puts #undef puts #endif #define puts(toto) print(toto);putchar('\n') if(!VOSC_JoystickDetected) puts("No joystick detected"); else puts("Joystick detected");
Peut-être y a t-il une solution que je ne connais pas?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 #ifdef printf #undef printf #endif #define printf(format, args ...) {sprintf(VOSC_PrintBuf,format, ## args); print(VOSC_PrintBuf)} #ifdef puts #undef puts #endif #define puts(toto) {print(toto);putchar('\n')} if(!VOSC_JoystickDetected) puts("No joystick detected"); else puts("Joystick detected");
A+
Pfeuh
Partager