LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Understanding DAQmxErrChk(functionCall)

Solved!
Go to solution

I  have seen this line in a couple of examples #define DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) goto Error; else

I would like to understand the purpose of this statement in the code. The argument functionCall to the function DAQmxErrChk isn't declared anywhere. I have searched for documentation that explains the purpose of the DAQmxErrChk but couldn't find any.

 

Any help is appreciated.

0 Kudos
Message 1 of 4
(2,823 Views)
Solution
Accepted by topic author SKSV

This isn't a function call, it's a macro! When you run your project the preprocessor comes in first and replaces every occurrence of the macros with their proper code; functionCall is the placeholder for the function enclosed in macro brackets. Thus, the code

#define DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) goto Error; else

DAQmxErrChk (DAQmxStartTask(taskHandle));

gets actually translated to

if( ((error=(DAQmxStartTask(taskHandle)))<0) ) goto Error; else;

(note that DAQmxFailed is actually another macro that is defined in nidaqmx.h)

 

You can see how code is handled by the proprocessor by running Options >> Preprocess Source File menu function and looking at the new code window that is generated.



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?
Message 2 of 4
(2,763 Views)

For some reason I cannot see Accept as solution Button

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

Never mind I found it after replying to the post above

 

0 Kudos
Message 4 of 4
(2,561 Views)