We recommend using Visual Studio 2017
This documentation is archived and is not being maintained.

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 fix this error, give the event and the event handler the same storage class.

The following sample generates C3703:

// C3703.cpp
// C3703 expected
#include <stdio.h>

class CEventSrc {
   __event static void MyEvent();

class CEventHandler {
   // delete the following line to resolve
   void MyHandler() {}

   // try the following line instead
   // static void MyHandler() {}

   void HookIt(CEventSrc* pSource) {
      __hook(CEventSrc::MyEvent, pSource, &CEventHandler::MyHandler);

   void UnhookIt(CEventSrc* pSource) {
      __unhook(CEventSrc::MyEvent, pSource, &CEventHandler::MyHandler);

int main() {
   CEventSrc src;
   CEventHandler hnd;

   __raise src.MyEvent();