Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

Compiler Error C3741

'class': must be a coclass when the 'layout_dependent' parameter of event_receiver = true

When layout_dependent=truefor an event_receiver class, then the class must also have the coclass attribute.

The following sample generates C3741

// C3741.cpp
// compile with: /c
// C3741 expected
#include <atlbase.h>
#include <atlcom.h>

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

// Delete the following line to resolve.
[ event_receiver(com, layout_dependent=true)]

// class or struct must be declared with coclass
// Uncomment the following line to resolve.
// [ event_receiver(com, layout_dependent=true), coclass, uuid("00000000-0000-0000-0000-000000000002")]
struct R : I {
   HRESULT f(){ return 0; }
   R(I* a){ __hook(I, a); }
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft. All rights reserved.