0

In c/c++ we made pointer of function

    __global__ void ckernel1(){

  printf("hello1\n");
}

and then

__device__ void (*pck1)() = ckernel1;

But when i want to do the same with pointer to struct or class function :

    struct x {
        int data_member;
        __device__ void f(){
            printf("just another hello");
        }
    };
__device__ void (*me)() =  &x::f;

the compiler said

error: a value of type "void (x::*)()" cannot be used to initialize an entity of type "void (*)()"
Bob8751
  • 46
  • 4
  • 1
    that's pointer to member and is a completely different beast – phuclv Jul 18 '22 at 14:48
  • A pointer to a class member function has the form `ret_type (class_name::*)(param_list)` – NathanOliver Jul 18 '22 at 14:48
  • [Compiler error: cannot convert function pointer to typedef function pointer](https://stackoverflow.com/q/72541376/995714), [Pointer to class data member "::*"](https://stackoverflow.com/q/670734/995714), [Whats the point of pointers to member functions?](https://stackoverflow.com/q/72419105/995714) – phuclv Jul 18 '22 at 14:53

0 Answers0