0

I'm trying to call a kernel wrapper foo from a C++ class. I've tried to do as suggested here below:

// In CPP.h:
class cls {
    extern "C" inline void foo();
}

// In Kernels.cu:
#include "CPP.h"
extern "C" inline void cls::foo() {
    // call kernels here
}

but this has not worked - I get a compiler errors:

  • CPP.h: invalid storage class for a class member
  • CPP.h: "cls::foo" was referenced but not defined
  • Kernels.cu: label "cls" was declared but never referenced

What's going wrong?

4

1 回答 1

2

你不应该用extern "C".

使用说明符创建一个包装器非成员函数extern "C",并让此函数调用您的类的方法(您还需要指定一个实例)。

于 2013-05-09T14:51:21.953 回答