Witam,
Mam problem z warunkiem w preprocesorze (kompilator GCC)
Poniższy program działa prawidłowo:
#include <stdio.h>
#define NUMB1 8000000UL
#define NUMB2 64
#define RESULT (int)((1778E-6 * NUMB1 / NUMB2 * 0.85)+0.5)
int main(void) {
printf("%d",RESULT);
return 0;
}
obliczając RESULT jako 189.
Gdy chcę dodać reakcję preprocesora (w postaci warningu) na wartość RESULT powyżej 100:
#if RESULT > 100
# warning "Jakiś tekst ...."
#endif
kompilator generuje błąd:
#include <stdio.h>
#define NUMB1 8000000UL
#define NUMB2 64
#define RESULT (int)((1778E-6 * NUMB1 / NUMB2 * 0.85)+0.5)
#if RESULT > 100
# warning "Jakiś tekst ...."
#endif
int main(void) {
printf("%d",RESULT);
return 0;
}
komunikaty błędów:
prog.c:6:21: error: missing binary operator before token "("
#define RESULT (int)((1778E-6 * NUMB1 / NUMB2 * 0.85)+0.5)
^
prog.c:8:5: note: in expansion of macro ‘RESULT’
#if RESULT > 100
^
Co robię źle?