"modifier is not allowed on a destructor" 在 VS2013 中使用 nvcc 编译时出错

"modifier is not allowed on a destructor" error when compiled with nvcc in VS2013

我在 Visual Studio 2013 年,正在尝试编译利用继承和 C++11 的 CUDA 代码。由于 "override".

,下面的代码 returns "modifier is not allowed on a destructor" 错误
// derived.cuh
class derived : public base
{
 public:
  derived();
  ~derived() override;
};

其中基类 class 的析构函数是虚拟的。完全相同的代码在 Ubuntu 上编译得很好。如果我将 .cu 和 .cuh 更改为 .cpp 和 .h,则完全相同的代码也可以使用默认的 Visual studio c++ 编译器进行编译。 C++11 已启用,因为如果 "override" 附加在普通函数上,它也可以正常编译。请参阅下面的示例,

// derived2.cuh
class derived2 : public base
{
 public:
  derived2();
  ~derived2();

  void func() override;
};  

其中 func() 是基 class 中的虚函数。

VS2013中使用nvcc编译时出现"modifier is not allowed on a destructor"错误如何解决?

向 NVIDIA 提交了这个错误,他们回复说这将在下一个 CUDA 版本(大概是 8.0)中修复。