We have 2 issues during using COSMIC Compiler 4.3.1 16k Limit version and STVD 4.1.3, R-Link.
First, we don’t have functional value through using Local Variable, when we use as above it shows different value on long_var. void main(void) { long long_var = 0; float float_var = 0; long_var = 533485489; float_var = (float)long_var; while (1) { } }
Second, Type Casting problem. long long_var = 533485489; float float_var = 0; void main(void) { float_var = (float)long_var; while (1) { } } It showed wrong value on float_var as it was inserted Type Casting after we declared global variable,
however, it goes properly in main function as follows. long long_var; float float_var = 0; void main(void) { long_var = 533485489; float_var = (float)long_var; while (1) { } }
also, when you work with local variables that are not actually used for anything, the compiler sometimes optimize them out: use globals or, at least, declare the locals volatile, to avoid this.