Hallo,
I use RealView compiler for c I like to assert a statement by procompiler
Writing:
int i; const int Ass_FR = sizeof(i); #if Ass_FR != 5 #error "Error!!!" #endif
is working.
but:
int i; #if sizeof(i) != 5 #error "Error!!!" #endif
not.
He says: error: #59: function call is not allowed in a constant expression
Is this a bug?
Runtimeerror is fatched by code and nice Display Message to user. Only, if the code is used with other compiler it couldn't work. Compiler is not very genius: if (sizeof(int) != 2) Fehler("xxx"); will not be removed by optimization. The Statement in if is constant.So he must know, that this is never true.
PS: Found bad bug in compiler while(changedbyInt){}; will only test changedbyInt once in ASM. But changedbyInt is changed by Interrupt.
HI.
<quote> PS: Found bad bug in compiler while(changedbyInt){}; will only test changedbyInt once in ASM. But changedbyInt is changed by Interrupt. </quote>
is yo're variable changedbyInt declared as volatile?
it should have.
Always yo're freind.
Zeusti.
PS: Found bad bug in compiler while(changedbyInt){}; will only test changedbyInt once in ASM. But changedbyInt is changed by Interrupt.<p>
No, you didn't find a bug. This is correct and expected behavior - by default, the compiler does not need to consider the possibility of the value of variables being changed outside the regular program flow (e.g. by interrupts, other processes, hardware, etc).
Using the keyword volatile when declaring the variable will instruct the compiler to assume that the value of the variable may change at any time.