简体   繁体   中英

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

I am on Visual Studio 2013 and is trying to compile a CUDA code that utilizes inheritance and C++11. The code below returns "modifier is not allowed on a destructor" error because of the "override".

// derived.cuh
class derived : public base
{
 public:
  derived();
  ~derived() override;
};

where the destructor of the base class is virtual. The exact same code compiles fine on Ubuntu. The exact same code also compiles fine with default Visual studio c++ compiler if I change the .cu and .cuh to .cpp and .h. C++11 is enabled because if the "override" is appended on a normal function it also compiles fine. See example below,

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

  void func() override;
};  

where func() is an virtual function in the base class.

How to get rid of the "modifier is not allowed on a destructor" error when compiled with nvcc in VS2013?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM