编译器错误 C3808

“type”:包含 ComImport 特性的类不能定义成员“member”,只允许定义 abstract 或 dllimport 函数

注解

派生自 ComImportAttribute 的类型无法定义成员

“/clr:pure”和“/clr:safe”编译器选项在 Visual Studio 2015 中已弃用,并且在 Visual Studio 2017 中不受支持

示例

以下示例生成 C3808。

// C3808.cpp
// compile with: /c /clr:pure user32.lib
using namespace System::Runtime::InteropServices;

[System::Runtime::InteropServices::ComImportAttribute()]
ref struct S1 {
   int f() {}   // C3808
   virtual int g() abstract;   // OK

   [DllImport("msvcrt.dll")]
   int printf(System::String ^, int i);   // OK
};