LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

What is errChk?

New to CVI.
 
What is errChk?  Where I find its definition?  What's errChk(1) means?
 
George Zou
0 Kudos
Message 1 of 3
(7,494 Views)
You can find the definition of errChk in toolbox.h. errChk is a convenient macro that allows you to structure your error handling code as an exception- handler -- something like a C-language version of the C++ try-catch block.

Normally errChk is used around a function call that can return an error. The macro evaluates the return value of the function, and if it's non-zero it jumps to the code following an "Error:" label that you should define at the bottom of the function. Normally the code after that error label will clean up any resources created by the function, and then propagate the error up to the calling function.

The use of errChk(1) is not very common, but is intended to always force the execution to jump to the Error handler with an error value of 1.

Luis
Message 2 of 3
(7,491 Views)
Ah.. looks like I made a mistake. An attentive coworker noted that errChk only jumps to the Error label if the error is negative -- not non-zero.

So, given that, an errChk(1) seems pretty useless. All it does is initialize the error variable to 1, for whatever reason.

Luis
0 Kudos
Message 3 of 3
(7,483 Views)