我刚刚从CUDA中的普通CHECK(call)
函数复制了一个函数,并在Google Colab 中使用nvcc_plugin
运行
#define CHECK(call)
{
const cudaError_t error = call;
if (error != cudaSuccess)
{
printf("Error: %s:%d, ", __FILE__, __LINE__);
printf("code:%d, reason: %sn", error, cudaGetErrorString(error));
exit(1);
}
}
但它引发了一个错误
/tmp/tmpvc2kvnuh/9c0f913f-6a2c-420d-9e3a-94c6e3123f7f.cu(9): error: expected a declaration
我该怎么做?
#define CHECK(call)
{
const cudaError_t error = call;
if (error != cudaSuccess)
{
printf("Error: %s:%d, ", __FILE__, __LINE__);
printf("code:%d, reason: %sn", error, cudaGetErrorString(error));
exit(1);
}
}
如果你想要一个多行宏,你必须添加反斜杠。