【问题标题】:Error : argument of type "int" is incompatible with parameter of type "const void *"错误:“int”类型的参数与“const void *”类型的参数不兼容
【发布时间】:2013-04-10 14:44:24
【问题描述】:

在我编译程序时的这部分代码。此错误显示:““int”类型的参数与“const void *”类型的参数不兼容。我声明变量如下:

int *dev_matrix, *dev_array, *dev_array_length;
int array_length=1;
cudaMalloc((void**)&dev_array_length, 1*sizeof(int));
cudaMemcpy(dev_array_length, array_length, 1*sizeof(int), cudaMemcpyHostToDevice);

【问题讨论】:

    标签: cuda


    【解决方案1】:

    cudaMemcpy() 的第二个参数是错误的。它是一个指针 (const void*),而您提供的是一个 int

    你的意思是写:

    cudaMemcpy(dev_array_length, &array_length, 1*sizeof(int), cudaMemcpyHostToDevice);
                                 ^
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-02-21
      • 1970-01-01
      • 2019-10-31
      • 1970-01-01
      • 1970-01-01
      • 2021-03-08
      • 1970-01-01
      相关资源
      最近更新 更多