Hi,
I´m trying to create a routine to validate my casting. What I want to do is if my structure size is right put some code, if the code should report an error.
Does anyone knows how can I do this at compile time?
BrunoCode:#define COMPILE_TIME_ASSERT(test, a) \
#if (test == 1) \
*(char*)&(a)\
#else\
"Structure size error!"\
#endif
#define BYTE(a) COMPILE_TIME_ASSERT(sizeof(a) == 1, a)
int main
{
char a,b;
b = BYTE(a);
BYTE(a) = a+1;
return a;
}