Compartir a través de


Error del compilador C3808

"type": una clase con el atributo ComImport no puede definir el miembro "member", solo se permiten las funciones abstract o dllimport

Comentarios

Un tipo derivado de ComImportAttribute no puede definir member.

Las opciones del compilador /clr:pure y /clr:safe están en desuso en Visual Studio 2015 y no se admiten en Visual Studio 2017.

Ejemplo

El ejemplo siguiente genera el error 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
};