LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

2013 SP1 Compiler issue

Solved!
Go to solution

Hello,

 

I am using LabWindows/CVI 2013 SP1. I built my application and there were no warnings or errors. When I ran my application I found that one of my numerical indicators was not being updated. When I looked at the code I saw my error and I could not believe the compiler did not catch this error during the build.

 

I recently switched the update function I used from 'SetCtrlVal' to 'SetCtrlAttribute'. My error was that I didn't add the additional argument that is needed by 'SetCtrlAttribute'.

 

The compiler should have caught that there were not enough arguments being sent to this function.

John O'C
Staff Test Systems Engineer
Woodward, Inc.
Skokie, Illinois, USA

"Life is not a journey to the grave with the intention of arriving safely
in a pretty and well preserved body, but rather to skid in broadside,
thoroughly used up, totally worn out, and loudly proclaiming...
Wow...What a Ride!"
0 Kudos
Message 1 of 3
(4,448 Views)
Solution
Accepted by topic author johnoc

Hello John,

 

You don't get a compilation error at compile time becasue SetCtrlAttribute takes as the 4th parameter a Variable Argument List.

The prototype of SetCtrlAttribute is:

int CVIFUNC_C SetCtrlAttribute(int panel, int control, int attribute, ...); 

 This means that after the first 3 parameters you can pass 0 or more parameters of any type.

It's the same case as printf; the prototype is:

int  CVIFUNC_C printf(const char *, ...);  

 You can write printf("Hello") as well as printf("Hello %s", "Word)

 

Although SetCtrlAttribute needs 4 parameters, the last parameter is declared as variable argument list(va_arg) because the 4th parameter can be of different type, depending on the attribute or the data type of the control.

 

However, if you don't put the 4th parameter or it has an incorrect type, you should get a run-time error in Debug configuration with run-time checking enabled(Debugging level set to Standard or Extended in Build Options).

 

fatal run-time error.png

 

Constantin

 

Message 2 of 3
(4,423 Views)

Thank you for clarifying Constantin!

John O'C
Staff Test Systems Engineer
Woodward, Inc.
Skokie, Illinois, USA

"Life is not a journey to the grave with the intention of arriving safely
in a pretty and well preserved body, but rather to skid in broadside,
thoroughly used up, totally worn out, and loudly proclaiming...
Wow...What a Ride!"
0 Kudos
Message 3 of 3
(4,405 Views)