In my code, a function returns a negative number to indicate an error. So instead of saying
error = foo ();
if (error < 0)
{
sprintf (errMsg, "Function foo returned %d", error);
goto Error:
}
...I instead have a macro "negChk" that lets me do this:
negChk (foo(), "foo");
As you can see, I must redundantly pass the function's name to the macro as a string. I'd rather just pass it like this:
negChk (foo());
Here's my macro now, how should I rewrite it to take just one parameter as shown above? ...
#define negChk(fCall, fName)\
\
error = (fCall);\
if (error) {\
testData->result = FAIL;\
sprintf (errMsg, "%s () failed, error code %d", fName, error);\
testData->replaceStr
ingFuncPtr(&testError->errorMessage, errMsg);\
testData->replaceStringFuncPtr (&testData->outBuffer, errMsg);\
if(error < 0) goto Error;\
} else