#define和CUDA

Kri*_*ato 3 c++ cuda c-preprocessor

为什么以下代码段不适用于CUDA(3.2和4.0)?

#define NUM_BLOCKS 16

// lots of code.

dim3 dimBlock(NUM_BLOCKS, NUM_BLOCKS);
Run Code Online (Sandbox Code Playgroud)

但是这个,

dim3 dimBlock(16, 16);
Run Code Online (Sandbox Code Playgroud)

呢?

我一直在error : expected a ")"error : expected an expression.我错过了什么?

Cyg*_*sX1 8

你确定你没写

#define NUM_BLOCKS 16;
Run Code Online (Sandbox Code Playgroud)

(注意结尾的分号)?

当错误的分号存在时,我得到你所描述的错误.