I need to implement something like this but using CMacro:
int a = //some constant;
int x = //constant
int c = //constant
int y = a*x+b;
I've tried something like:
#define A 3
#define X 6
#define B 8
#define Y ((A)*(X) + (B))
However if I use the flag -E
in the gcc it shows me 3*6 + 8
.
Isn't there any way to perform integer arithmetic using CMacro, before the substitution I mean?
My purpose would be something like, just a piece of code...:
#define func_impl(NY,NX,R) \
void func_#NY_#NX(int* y, int* x) { \ //x size NX, y size NY
int tmp[2*NX - R]; \
for(int i = 0; i < 2*NX - R; i++) tmp[i] = 0; \
//other processing operations... \
}
I know both NX, NY and R a priori, although they're generated by another program. So basically I want to avoid to let the program P1 to generate too many macro constants if possible.