Hi,
I have a problem with #if in preprocesor (gcc-4.8.1).
Such program works fine:
Code:
#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;
}
the RESULT has correct value 189.
But when I want define warning reaction of value of RESULT like this:
Code:
#if RESULT > 100
# warning "Some text ...."
#endif
the compiler does not compile the program:
Code:
#include <stdio.h>
#define NUMB1 8000000UL
#define NUMB2 64
#define RESULT (int)((1778E-6 * NUMB1 / NUMB2 * 0.85)+0.5)
#if RESULT > 100
# warning "Some text ...."
#endif
int main(void) {
printf("%d",RESULT);
return 0;
}
errors:
Code:
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
^
What am I doing wrong?