08-07-2014 10:28 AM
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.
Solved! Go to Solution.
08-08-2014 03:23 AM - edited 08-08-2014 03:26 AM
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).
Constantin
08-08-2014 08:30 AM
Thank you for clarifying Constantin!