Quote:
|
Originally Posted by Mike Betts
2. Just what is the value of an uninitialized variable? Answer: It is undefined. If you are lucky, it will be 0x0000 or 0xFFFF. If you are unlucky, it can be anything.
My point here is that it is impossible to do what you suggest in an embedded controller.
|
Actually, it is possible. If you assign an initial value to a static variable, the C compiler will automatically generate code to put the correct value in that location in RAM. This code is hidden from the user and is called before control is passed to the C program's entry point (usually main()).
{edit} The code that does this is in _do_cinit() in ifi_startup.c {/edit}
{edit2} But I agree with you that if you modify the default code then it becomes your responsibility to ensure there's no bugs. It would be impossible for IFI to protect the end users against all of the various mistakes like this that are possible. {/edit}