LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Array initialization

Solved!
Go to solution

if I declare an array

double test_values [] = {20.0, 30.0, 50.5, 101.5, 200.5};

if(debug)

{

    test_values [] = {20.0, 30.0,};

}

......

I got a compile error: expected expression

but if I do this

double test_values [] = {20.0, 30.0, 50.5, 101.5, 200.5};

if(debug)

{

    double test_values [] = {20.0, 30.0,};

}

......

during debug I found that the code stepped into the debug loop but the test_values array still have the original values (5 elements) instead of the debug values (2 elements)

I'm using LabWindows CVI 2015

Thanks in advance if you can help to answer

 

0 Kudos
Message 1 of 2
(2,888 Views)
Solution
Accepted by topic author Son_La

The reason for the first error is quite clear: the compiler assumes you want to assign an array element a value, but complains that no actual element is stated.

 

As per your second example, I don't think you can resize the array this way. I would rather rephrase the code using some preprocessor directive:

#ifdef _CVI_DEBUG_
	double test_values [] = {20.0, 30.0};
#else
	double test_values [] = {20.0, 30.0, 50.5, 101.5, 200.5};
#endif 

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 2
(2,862 Views)