LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Parameter evaluation order - CVI 2012 vs. 2013

Here's something I just recently got burned with.  It turns out that CVI 2013 evaluates parameters in a function call in a different order than CVI 2012.  Take this code for example:

 

#include <stdio.h>

void multiprint(int arg1, int arg2, int arg3, int arg4, int arg5)
{
	printf("%d, %d, %d, %d, %d\n", arg1, arg2, arg3, arg4, arg5);

	return ;
}


int main(int argc, char *argv[])
{
	int i = 5;

	multiprint(i--, i--, i--, i--, i--);

	return 0;
}

 

In CVI 2012, this will print:

1, 2, 3, 4, 5

 

In CVI 2013, this will print:

5, 4, 3, 2, 1

 

Smiley Surprised

 

I actually did some digging on this, and it turns out that the order that parameters in a function call are evaluated in C is undefined, which means that while CVI 2013 compiles this code differently than CVI 2012, neither one of them are doing anything incorrect (per the specfication).

 

Anyhow, just something to watch out for if you're migrating projects to CVI 2013!  Smiley Happy

 

0 Kudos
Message 1 of 3
(4,617 Views)

Hi,

 

Thank you for pointing this out.  As you mentioned, the compiler has changed between the 2012 and 2013 versions of CVI.  CVI 2012 uses a custom CVI compiler, whereas CVI 2013 switched over to the clang compiler.

 

 

Regards,

0 Kudos
Message 2 of 3
(4,582 Views)

Hi tstanley,

 

Thank you for your post! I will make sure this behavior change makes it to the list of behavior changes for LabWindows/CVI 2013.

 

Warm regards,

Daniel Dorroh
National Instruments
0 Kudos
Message 3 of 3
(4,557 Views)