我的C代码中有这个宏:
#define ASSERT(ret, num) \ // make sure ret === num
if (ret != num) { \
fprintf(stderr, "Error [%d] at line [%d] in function [%s]. Date: [%s] Time: [%s]\n", \
ret, __LINE__, __FUNCTION__, __DATE__, __TIME__); \
exit(ret); \
}
然后我这样称呼它(所有参数都是整数):
ASSERT(errNo, MPI_SUCCESS);
ASSERT(aliveNeighbors, 8);
ASSERT(newGrid, !NULL);
我收到错误(GCC v5.4):
expected identifier or ‘(’ before ‘if’
if (ret != num) { \
error: stray ‘\’ in program
ASSERT(errNo, MPI_SUCCESS);
error: stray ‘\’ in program
ASSERT(aliveNeighbors, 8);
stray ‘\’ in program
ASSERT(newGrid, !NULL);
这里有什么问题?