NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Compiler Error C3703

'event handler': an event handler method must have the same storage class as the source 'event'

An event has a different storage class than the event handler to which it is hooked. For example, this error occurs if the event handler is a static member function and the event is not static. To resolve the error, give the event and the event handler the same storage class.

The following sample generates C3703:

#include <stdio.h>

[event_source(type=native)]
class CEventSrc {
public:
   __event static void MyEvent();
};

[event_receiver(type=native)]
class CEventHandler {
public:
   void MyHandler() {
   // try the following function declaration instead
   // static void MyHandler() {
      printf("MyHandler was called.\n");
   }

   void HookIt(CEventSrc* pSource) {
      __hook(CEventSrc::MyEvent, pSource, MyHandler);    // C3703
   }

   void UnhookIt(CEventSrc* pSource) {
      __unhook(CEventSrc::MyEvent, pSource, MyHandler);  // C3703
   }
};

void main() {
   CEventSrc src;
   CEventHandler hnd;

   hnd.HookIt(&src);
   __raise src.MyEvent();
   hnd.UnhookIt(&src);
}