Discussion of issues related specifically to writing code for native mode devices. This includes ZBasic code as well as assembly language code and C code, both inline and standalone.
I've been getting this warning while now (it's not due to the newest compiler release). The application functions properly by all accounts, although the particular function where the warning is coming from is as yet unfinished.
ModbusTask.c: In function 'zf_ModbusTask':
ModbusTask.c:28: warning: 'zv_DataCount' may be used uninitialized in this function
The warning is issued even if the variable is manually given a value immediately after declaration, such as:
Dim I as Integer
Dim BitTIme as Single
Dim AddressField as Byte
Dim OldQCount as Integer
Dim DataCount as Integer
DataCount = 1
Dim CRC as UnsignedInteger
Dim ReceivedCRC as UnsignedInteger
The corrosponding C code does not seem to set the variable at all:
I'm not necessarily concerned about the warning, but for the sake of commenting my code, I'd like to identify the issue, and at the very least make note of it.
Don_Kirby wrote:I'd like to identify the issue, and at the very least make note of it.
In most cases that I've seen, the warning that you referred to is valid. I have seen a few cases where the logic guaranteed that the variable wouldn't be used unless it was initialized.
In any event, I'd like to see the ZBasic code that led to this warning so that I can see what can be done to eliminate it.
In trying to isolate the problem, I've determined that when the task is taken out of the context of the application, the warning goes away. I'll need to do a bit more work to get a smaller test application to behave the in the same manner as the entire application.
Two other things:
It seems that the compiler is incorrectly reporting the amount of persistent memory in use:
It should be over 900 bytes. This is almost certainly not related to the warning issue.
Also, if I double click on the warning in the compiler output pane, the IDE jumps to the offending line number in the ZBasic code, which doesn't correspond at all to the C code to which the warning is referring to.
Don_Kirby wrote:I'll need to do a bit more work to get a smaller test application to behave the in the same manner as the entire application.
If you don't mind sending me the whole application, I can work directly with it. That way, you won't have to spend time trying to reproduce it in a small test case.