次の方法で共有


コンパイラ エラー C3808

'type' : ComImport 属性を伴うクラスは、メンバー 'member' を定義することはできません。抽象関数または dllimport 関数のみを使用することができます

解説

ComImportAttribute から派生した型では、member を定義できません。

/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
};