01-30-2020 10:32 AM
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.
Solved! Go to Solution.
01-31-2020 12:38 AM
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.
02-07-2020 10:08 AM
For some reason I cannot see Accept as solution Button
02-07-2020 10:09 AM
Never mind I found it after replying to the post above