From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Unexpected build warnings in CVI 7.0

Hi,
I have just migrated to CVI7.0. When I compile the following code fragment I get a build warning that suggests that mean_volts is not fully initialized:

double mean_volts[TOTAL_AI_CHANNELS];
...
for (i=0; i Mean (volts + (i * CONC_BKD_PTS_PER_CH), BKD_PTS_PER_CH, mean_volts + i);

mean_volts[RAW_INIT_SAMP_TC-1] += samp_tc_ref_volts; //<--warning here
mean_volts[RAW_INIT_VESS_TC-1] += vess_tc_ref_volts; //<--and here!

Why is this? I didn't get it in CVI6.

Regards

Jamie Fraser
0 Kudos
Message 1 of 9
(3,169 Views)
Jamie,

Does the warning state that "Local 'mean_volts' might not have been initialized" or does it state that "Local 'mean_volts' has not been initialized"?

If it's the former, then what has probably happened is that your "Uninitialized Local Variables Detection" mode is set to "Agressive". When you were using CVI 6, you probably had it set to "Conservative" (you set this in Options>>Build Options)

In Agressive mode you get a warning whenever a variable is, or is not, initialized depending on the code path taken at runtime (in this case, it depends on whether the for-loop initializes the RAW_INIT_SAMP_TC and RAW_INIT_VESS_TC elements). Because the compiler can't know for sure, it gives you the warning.
In reality, if you're using run-time detection as well,
you have no need to ever use Agressive. If the code path for some reason did not initialize everything, you would get a run-time error, so you would still be safe.

Luis
NI
0 Kudos
Message 2 of 9
(3,169 Views)
Luis,

Thanks for your response.
It is set to Conservative which is why I was suprised. Setting to Aggressive gives a load of "might not be initialized" warnings, as well as the "has not been initialized" warnings that I mentioned.

It looks as though the compiler is missing the fact that all elements of the array have been initialized by the for loop.

Look forward to your further comments.

Regards

Jamie Fraser
0 Kudos
Message 3 of 9
(3,169 Views)
Hmmm... I wasn't expecting that 🙂

In order to find out why it's happening I will need to be able to reproduce it here. When I tried compiling the code you included, making up random values for the macros in the code, I only got the "might not" warnings...

Could you attach a compilable code snippet that reproduces the problem?

- luis
0 Kudos
Message 4 of 9
(3,169 Views)
Luis,

The plot thickens a little. The build errors do not always appear when compiling, but you seem to be able to force them by switching to Aggressive checking. They appear amongst the many build warnings in the Aggressive check results, then, when you switch back to Conservative checking, there they are all on their own.

For simplicity I have attached the whole app. You will notice there are a couple of other arrays that also get thrown up with the same warning, but these are in a function that I is not well written, however, CVI 6.0 did not give warnings for these either.

asynctmr.fp is used.

Regards

Jamie Fraser
Download All
0 Kudos
Message 5 of 9
(3,169 Views)
Jamie,

When I tried compiling your file in Conservative mode, I don't get the warnings in the lines of code that you had indicated (lines 5164 and 5165), but I do get the warning in lines 5195 and 5196. In either case, it seems to me that the warning is incorrect, so I'm not too concerned about seeing in a different place (I also get two other warnings, in lines 4705 and 4707 that also seem incorrect).

I also confirmed that none of the warnings are displayed in CVI 6.

We'll have to investigate this in more detail, and it might take a few weeks before we get to it (I'm assuming that this isn't an emergency; you can just ignore those warnings for now). Once we find and fix the problem, we'll let you know what's going on.

Th
anks for reporting this!

- luis
0 Kudos
Message 6 of 9
(3,169 Views)
Luis,

Thanks for investigating this. I had actually copied the wrong lines of code into my snippet. The ones that gave you the error are the same as the ones that gave me the error.

I look forward to your findings.

Regards

Jamie Fraser
0 Kudos
Message 7 of 9
(3,169 Views)
Jamie,

We found the cause of the problem and fixed it. The fix will be in the
next version of CVI.

- luis
0 Kudos
Message 8 of 9
(3,169 Views)
Luis,

Thanks for the investigation and follow-up. Excellent support.

Jamie Fraser
0 Kudos
Message 9 of 9
(3,169 Views)