title: 'cannot convert from...' error during callback assignations (migrated code from C)
body: <p>I'm migrating some lines coded on C to C++/CLI (UI Windows Form based on .NET). One of my problems comes when I try to do this kind of assignation:</p>
  
  <pre><code>myCallbacks.cbf_data_write = this-&gt;dataWriteFunc;
  </code></pre>
  
  <p>In this case, dataWriteFunc is defined as:</p>
  
  <pre><code>PNIO_IOXS dataWriteFunc(PNIO_UINT32, PNIO_DEV_ADDR *, PNIO_UINT32, PNIO_UINT8 *, PNIO_IOXS);
  </code></pre>
  
  <p>And myCallbacks is declared as</p>
  
  <pre><code>PNIOD_CBF_FUNCTIONS myCallbacks;
  </code></pre>
  
  <p>with</p>
  
  <pre><code>typedef struct {
      PNIO_UINT32                      size;                      /* size of struct = sizeof(PNIO_CBF_FUNCTIONS) */
      PNIO_CBF_DATA_WRITE              cbf_data_write;            /* mandatory */
      PNIO_CBF_DATA_READ               cbf_data_read;             /* mandatory */
      PNIOD_CBF_ASYNC_REC_READ         cbf_async_rec_read;        /* mandatory */
      PNIOD_CBF_ASYNC_REC_WRITE        cbf_async_rec_write;       /* mandatory */
      PNIOD_CBF_SYNC_ALARM_DONE        cbf_sync_alarm_done;       /* mandatory */
      PNIOD_CBF_ASYNC_CONNECT_IND      cbf_async_connect_ind;     /* mandatory */
      PNIOD_CBF_ASYNC_OWNERSHIP_IND    cbf_async_ownership_ind;   /* mandatory */
      PNIOD_CBF_ASYNC_INDATA_IND       cbf_async_indata_ind;      /* mandatory */
      PNIOD_CBF_SYNC_DISCONNECT_IND    cbf_sync_disconnect_ind;   /* mandatory */
      PNIOD_CBF_SYNC_DATA_STATUS_IND   cbf_sync_data_status_ind;  /* mandatory */
      PNIOD_CBF_ASYNC_PRM_END_IND      cbf_async_prm_end_ind;     /* mandatory */
      PNIOD_CBF_SYNC_STOPPED           cbf_sync_device_stopped;   /* mandatory */
      PNIOD_CBF_ASYNC_IRT_INIT_INPUTS  cbf_async_irt_init_inputs; /* mandatory for IRT top */
      PNIOD_CBF_SYNC_CP_STOP_REQ       cbf_sync_cp_stop_req;      /* optional */
      PNIOD_CBF_SYNC_START_LED_FLASH   cbf_sync_start_led_flash;  /* optional */
      PNIOD_CBF_SYNC_STOP_LED_FLASH    cbf_sync_stop_led_flash;   /* optional */
      PNIOD_CBF_RESERVED
  } ATTR_PACKED PNIOD_CBF_FUNCTIONS;
  </code></pre>
  
  <p>Also:</p>
  
  <pre><code>typedef PNIO_IOXS    (*PNIO_CBF_DATA_WRITE) /* write data to IO stack (local ==&gt; remote) */
         (PNIO_UINT32          DevHndl,       /* Handle for Multidevice */
          PNIO_DEV_ADDR      * pAddr,         /* geographical address */
          PNIO_UINT32          BufLen,        /* length of the submodule input data */
          PNIO_UINT8         * pBuffer,       /* Ptr to data buffer to write to */
          PNIO_IOXS            Iocs);         /* remote (io controller) consumer status */
  </code></pre>
  
  <p>So, what exactly I'm doing wrong? VS2012 gives me next error:</p>
  
  <pre><code>Error   4   error C2440: '=' : cannot convert from 'PNIO_IOXS (__thiscall CP1626::* )(PNIO_UINT32,PNIO_DEV_ADDR *,PNIO_UINT32,PNIO_UINT8 *,PNIO_IOXS)' to 'PNIO_CBF_DATA_WRITE' c:\users\hp\documents\visual studio 2012\projects\ui_cp1626\ui_cp1626\Profinet_IDevice.h    513 1   UI_CP1626
  </code></pre>
  
  <p>What's the correct form to associate callbacks in this case?</p>
  
  <p>Thank you in advance.</p>