簡體   English   中英

在VS2013中使用nvcc編譯時,“析構函數上不允許使用修飾符”錯誤

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

我在Visual Studio 2013上,正在嘗試編譯一個利用繼承和C ++ 11的CUDA代碼。 由於“覆蓋”,下面的代碼返回“析構函數不允許修飾符”錯誤。

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

基類的析構函數是虛擬的。 完全相同的代碼在Ubuntu上編譯得很好。 如果我將.cu和.cuh更改為.cpp和.h,完全相同的代碼也可以使用默認的Visual Studio c ++編譯器編譯。 C ++ 11已啟用,因為如果“覆蓋”附加在普通函數上,它也可以編譯。 見下面的例子,

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

  void func() override;
};  

其中func()是基類中的虛函數。

在VS2013中使用nvcc編譯時如何擺脫“修改器不允許在析構函數上”錯誤?

將此錯誤提交給NVIDIA,他們回復說這將在下一個CUDA版本中修復(大概是8.0)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM