Topic : Problem with pre-defined constant not folded at a compile time

Forum : 8051

Original Post
Post Information Post
March 10, 2011 - 2:55pm

I have an issue with one of the macros I'm using to calculate the size of a struct.


By analysing the code space requirements it seems that in one case this macro is not pre-calculated at a compile time but compiled into the code and calculated during runtime. I'm using a few of these macros for calculating the size of structs and they get folded properly but I have just one single case with one single struct where the folding doesn't happen. Furthermore I pasted in that struct into a different project along with the define, attempted to use that constant in the code and the value was pre-calculated by the compiler as expected so it doesn't seem to be an issue with the particular struct.

Are there any circumstances where such a macro calculating the pre-defined struct size would not be evaluated at a compile-time?

I'm using Ride and RKit-51 My project uses code banking so apart from C sources there is one assembly file linked in (l51bank.a51) if that should matter.

Post Information Post
March 11, 2011 - 10:41am
Raisonance Support Team

sizeof(struct) IS a constant!

Could you show us the C code and the assembler code where it isn't pre-calculated at compile time?