mchen
mchen

Reputation: 10166

Calling inline function in .cu file from C++ class

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:

What's going wrong?

Upvotes: 0

Views: 527

Answers (1)

nullptr
nullptr

Reputation: 11058

You shouldn't mark a class method with extern "C".

Make a wrapper non-member function with extern "C" specifier, and let this function call your class's method (you will need to specify an instance also).

Upvotes: 2

Related Questions