LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple unsequenced modifications to 'i' warning

Solved!
Go to solution

Hello all,

I am receving a sequence of 12-bit binary integers from a microprocessor and I want to decode them.

My code is the following:

unsigned short		mm1 = 0, mm2 = 0, mm3 = 0;
int		i;
char		buf[64];

i = 0;
mm1 = (buf[i++] << 8) + buf[i++];
mm2 = (buf[i++] << 8) + buf[i++];
mm3 = (buf[i++] << 8) + buf[i++];

The compiler issues the following: "warning: multiple unsequenced modifications to 'i' ", however returned values are correct (er, they were in CVI2012: I am porting some code to 2015 but still haven't tested it).

What does it means? How can I get rid of the warning?



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 1 of 3
(12,133 Views)
Solution
Accepted by topic author RobertoBozzolo

Hello Roberto

 

It means that the compiler doesn't guarantees the order "++" operation is performed in relation to other access of variable i; That is when the 2nd i++ is executed you are not sure if i was already incremented or it will be incremented twice at the end.

To get rid of the warning you have to split the i++ operations in different instructions.

 

mm1 = (buf[i++] << 8) ;
mm1 += buf[i++];

Related thread: CVI 2013 compiler: increment / decrement operator evaluation

 

Cosntantin

 

0 Kudos
Message 2 of 3
(12,122 Views)

Wow, this opens a whole new world of arguments to study! Smiley Surprised

 

I can get rid of any ++ operator with the following code that seems to work:

for (i = 0, j = 0; i < 6; j++, i+=2) {
   mm[j] = (buf[i] << 8) + buf[i + 1];
}

 



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 3 of 3
(12,103 Views)