none
error C2276: '&' : illegal operation on bound member function expression_Visual C++ 2008

    Question

  • Dear All,

    I would like to ask of how to fix error  C2276: '&' : illegal operation on bound member function expression. I am using Visual C++ 2008 CLR Windows.

     

    Below are  the code that i have :

    Source code:

       
        void    sendCallback(cb_DataSendInfo_t* sendInfos);
        int8_t    receiveCallback(cb_DataReceivedInfo_t* rcvInfos);
        int8_t    receiveDMCallback(cb_DataReceivedInfo_t* rcvInfos);
        void    claimEvent(cb_ClaimEventInfo_t* infos);
        int8_t    receivedTPAnnounce(cb_PGNAnnounceInfo_t* infos);
        void    receivedRequest(cb_RequestReceivedInfo_t* infos);
        int        runDevice(void);

     


        /* set the callbacks: */
        j_setCallback_RequestReceived(0, &receivedRequest);
        j_setCallback_PGNAnnounce(0, &receivedTPAnnounce);
        j_setCallback_ClaimEvent(0, &claimEvent);
        j_setCallback_PGNSend(0, &sendCallback);
        j_setCallback_PGNReceived(0, &receiveCallback);
        j_setCallback_DMReceived(0, &receiveDMCallback);

     

     

    .h (header):




    typedef struct {
        uint32_t        pgn;        
        uint32_t        customData;    
        uint8_t*        data;        
        int16_t            offset;        
        uint8_t            fromAddr;
        uint8_t            destAddr;    
        uint8_t            dataLen;    
        int8_t            status;        
        uint8_t            deviceNum;    
    } cb_DataReceivedInfo_t;


    typedef struct {
        uint32_t        pgn;        
        const uint8_t*    data;        
        uint16_t        offset;        
        uint16_t        nBytes;        
        uint8_t            destAddr;    
        uint8_t            deviceNum;    
    } cb_DataSendInfo_t;


    typedef struct {
        uint32_t        pgn;        
        uint32_t        customData;    
        uint16_t        msgSize;    
        uint8_t            fromAddr;    
        uint8_t            destAddr;    
        uint8_t            deviceNum;    
    } cb_PGNAnnounceInfo_t;

    typedef struct {
        uint32_t        pgn;        
        uint8_t            fromAddr;    
        uint8_t            toGlobal;    
        uint8_t            deviceNum;    
    } cb_RequestReceivedInfo_t;


    typedef struct {
        uint8_t*        deviceName;    
        uint8_t            evtType;    
        uint8_t            addr;        
        uint8_t            deviceNum;    

    typedef struct {
        uint32_t        pgn;        
        const uint8_t*    data;        
        uint16_t        dataLen;    
        uint8_t            destAddr;    
        uint8_t            priority;    
    } dataSendInfo_t;


    Can anyone help on how to fix the code ?

     

     

    Thanks very much

     

    Sue

     

     

    Wednesday, September 29, 2010 10:27 AM

Answers

All replies

  • Dear All,

    I would like to ask of how to fix error  C2276: '&' : illegal operation on bound member function expression. I am using Visual C++ 2008 CLR Windows.

     

    Below are  the code that i have :

    Source code:

       
        void    sendCallback(cb_DataSendInfo_t* sendInfos);
        int8_t    receiveCallback(cb_DataReceivedInfo_t* rcvInfos);
        int8_t    receiveDMCallback(cb_DataReceivedInfo_t* rcvInfos);
        void    claimEvent(cb_ClaimEventInfo_t* infos);
        int8_t    receivedTPAnnounce(cb_PGNAnnounceInfo_t* infos);
        void    receivedRequest(cb_RequestReceivedInfo_t* infos);
        int        runDevice(void);

     


        /* set the callbacks: */
        j_setCallback_RequestReceived(0, &receivedRequest);
        j_setCallback_PGNAnnounce(0, &receivedTPAnnounce);
        j_setCallback_ClaimEvent(0, &claimEvent);
        j_setCallback_PGNSend(0, &sendCallback);
        j_setCallback_PGNReceived(0, &receiveCallback);
        j_setCallback_DMReceived(0, &receiveDMCallback);

     

     

    .h (header):




    typedef struct {
        uint32_t        pgn;        
        uint32_t        customData;    
        uint8_t*        data;        
        int16_t            offset;        
        uint8_t            fromAddr;
        uint8_t            destAddr;    
        uint8_t            dataLen;    
        int8_t            status;        
        uint8_t            deviceNum;    
    } cb_DataReceivedInfo_t;


    typedef struct {
        uint32_t        pgn;        
        const uint8_t*    data;        
        uint16_t        offset;        
        uint16_t        nBytes;        
        uint8_t            destAddr;    
        uint8_t            deviceNum;    
    } cb_DataSendInfo_t;


    typedef struct {
        uint32_t        pgn;        
        uint32_t        customData;    
        uint16_t        msgSize;    
        uint8_t            fromAddr;    
        uint8_t            destAddr;    
        uint8_t            deviceNum;    
    } cb_PGNAnnounceInfo_t;

    typedef struct {
        uint32_t        pgn;        
        uint8_t            fromAddr;    
        uint8_t            toGlobal;    
        uint8_t            deviceNum;    
    } cb_RequestReceivedInfo_t;


    typedef struct {
        uint8_t*        deviceName;    
        uint8_t            evtType;    
        uint8_t            addr;        
        uint8_t            deviceNum;    

    typedef struct {
        uint32_t        pgn;        
        const uint8_t*    data;        
        uint16_t        dataLen;    
        uint8_t            destAddr;    
        uint8_t            priority;    
    } dataSendInfo_t;


    Can anyone help on how to fix the code ?

     

     

    Thanks very much

     

    Sue

     

     


    Does anyone has a suggestion on how to fix this illegal operation on bound member function.....???

     

    Thank you,

     

    Sue

    Wednesday, September 29, 2010 4:16 PM
  • At what scope are those functions declared? Are they free functions or class members?
    Wednesday, September 29, 2010 4:20 PM
  • At what scope are those functions declared? Are they free functions or class members?

    Hello there,

     

    Those functions declared as class members of public ref class Form1 (on CLR windows form). Is this an issue to declare it that way ? Thank you for your help,

     

    Sue

    Wednesday, September 29, 2010 4:48 PM
  • Yes -- among other reasons, j_setCallback_RequestReceived, j_setCallback_PGNAnnounce, etc almost certainly do not take member function pointers as arguments. Declare your functions as free functions instead of as class members.
    Wednesday, September 29, 2010 4:54 PM
  • This is related to your other post as well.

    Just a footnote comment, Sue: I suggest you consider to implement the GUI functionality in C#, where there is rich support, and reserve the C++ implementation to the aspect involving device communication. I think you will find the implementation more straightforward, and certainly the person supporting the code will be a lot happier as well.

    Wednesday, September 29, 2010 5:46 PM
  • Yes -- among other reasons, j_setCallback_RequestReceived, j_setCallback_PGNAnnounce, etc almost certainly do not take member function pointers as arguments. Declare your functions as free functions instead of as class members.


    Dear,

     

    Can you please clarify your point ? What the reason that j_setCallback_RequestReceived cant take pointer as argument ? It does work fine on CLI though.

     

    Thanks for your advise,

     

    Sue

    Thursday, September 30, 2010 2:27 AM
  • You've not shown the definition of j_setCallback_RequestReceived, so I'm not sure exactly what it takes. But as a guess, I assume it takes a function pointer, rather than a member function pointer. This is an important distinction.
    Thursday, September 30, 2010 3:45 AM
  • And why can't you use a member function?

    I want the callback to be encapsulated, not a static function.

    One member function of an instantiated class should be able to pass by reference a pointer to another member of the same instantiated class shouldn't it?

    Explain please?


    • Edited by _Andy__ Friday, August 15, 2014 4:27 PM
    Friday, August 15, 2014 4:27 PM