Udostępnij za pomocą


Błąd kompilatora C3719

"interface": źródło zdarzeń oparte na interfejsie może być używane tylko w przypadku zdarzeń COM

Uwagi

Zadeklarowaliśmy interfejs w kontekście innych niż COM.

Example

Poniższy przykład generuje kod błędu C3719.

// C3719a.cpp
#define _ATL_ATTRIBUTES 1
#include "atlbase.h"
#include "atlcom.h"

[module(name="MyLibrary", version="1.2", helpfile="MyHelpFile")];

[object]
__interface I {
   HRESULT func1();
};

[event_source(native), coclass]
struct A {
   __event __interface I;   // C3719

   // try the following line instead
   // __event func2();
};

int main() {
}

Aby naprawić ten błąd, zastosuj obiekt, klasę współklasy, event_source i atrybuty event_receiver odpowiednio, aby klasy, w których są używane klasy COM interfejsu. Na przykład:

// C3719b.cpp
#define _ATL_ATTRIBUTES 1
#include <atlbase.h>
#include <atlcom.h>

[module(name="xx")];
[object, uuid("00000000-0000-0000-0000-000000000001")]
__interface I {
   HRESULT f();
};

[coclass, event_source(com) , uuid("00000000-0000-0000-0000-000000000002")]
struct MyStruct {
   __event __interface I;
};

[event_receiver(com)]
struct MyStruct2 {
   void f() {
   }
   MyStruct2(I* pB) {
      __hook(&I::f, pB, &MyStruct2::f);
   }
};

int main()
{
}