title: C++: Creating a Callback function of the correct type
body: <p>I am working on a wrapper to use a hardware component in python using a dll provided by the manufactuer. The DLL comes with header and lib files so it is easy to include the dll. 
  As far as I understand, the compnent is used by calling the open function giving some initial parameters a callback function and some additional user data to it and then call the start method. In the following the component will deliver data by calling the callback function.</p>
  
  <p>The header of the dll looks something like this:</p>
  
  <pre><code>#ifndef COMPONENT_DLL_INCLUDED
  #define COMPONENT_DLL_INCLUDED
  
  #pragma once
  
   #ifndef DYNAMIC_COMPONENT_DLL_LINKAGE
  
    // to allow include in C- and C++-code
    #ifndef DLL_DECLSPEC
     #ifdef __cplusplus
       #define DLL_DECLSPEC  extern "C" __declspec(dllimport)
     #else
       #define DLL_DECLSPEC  __declspec(dllimport)
     #endif
    #endif
  
  typedef struct{
      eInformationType   type;
      eResultType        error;
      ComponentInfo      info;
  }AsyncInfo;
  
  typedef struct{                      
      BOOL         someParameter; 
      BOOL         someParameter2;
  } ParamSet1;
  
  typedef enum eType {
    UndefinedType   = 0x0,       
    Type1           = 0x1,        
    Type2           = 0x2         
  } Param2;
  
  
  // exported type SendAsynInformation
  typedef void ( CALLBACK *SendAsyncInformation )( const AsyncInfo&amp;, void *userInfo);
  
  // exported functions
    DLL_DECLSPEC  eResultType COMPONENT_Open( const ParamSet1 Set1, const Param2 P2, SendAsyncInformation SendAsyncInfo, void *userInfo );
    DLL_DECLSPEC  eResultType COMPONENT_Start( void );
  </code></pre>
  
  <p>My question is, how must my callback function look like? I tried things like</p>
  
  <pre><code>void myCallback(AsyncInfo *Info, myGlobals *g)
  {
      ...something...
  }
  </code></pre>
  
  <p>and then pass this callback to the open function:</p>
  
  <pre><code>COMPONENT_Open(mySet1, myP2, myCallback, myVoidPtr);
  </code></pre>
  
  <p>But I always get errors like:</p>
  
  <pre><code>...cannot convert argument 3 from 'void (__cdecl *)(AsyncInfo *,myGlobals *)' to 'SendAsyncInformation'
  </code></pre>
  
  <p>I am rather new to C++ so most likely this is a trivial question. I tried numerous things, but I don't see how to do it right. So, what is my mistake?  </p>