编译器错误 C3739

“class”: 仅当 event_receiver 的“layout_dependent”参数为 true 时才支持此语法

你尝试挂钩整个事件接口,但 event_receiver 属性上的 layout_dependent 不正确;必须一次挂钩一个事件。

以下示例生成 C3739:

// C3739.cpp
struct A
{
   __event void e();
};

// event_receiver is implied
// [ event_receiver(layout_dependent=false)]

// use the following line instead
// [event_receiver(com, layout_dependent=true), coclass ]
struct B
{
   void f();
   B(A* a)
   {
      __hook(A, a, &B::f);   // C3739
      // use the following line instead to hook a single event
      // __hook(&A::e, a, &B::f);
   }
};

int main()
{
}