I want to write preprocessor functions/arrays that are evaluated at compile time. For example, if I define
#define MYARR[] {5,4,3,2,1,0}
then, the code
int x = R[0];
should be presented as
int x = 5;
to the compiler. (of course only literals can be used in the index). This is important if code size/memory is critical and we dont want to store MYARR, but we need it for coding convenience.
Compile time functions would also be good. For example, something like
#define MYMAP(n)
#if n==1
5
#else
2
So, the statement
int x = MYMAP(4);
should be presented to the compiler as
int x = 2;
Obviously, we have to use a literal as the argument. Is this possible?
Thanks!