How to use MyMessage .setDestination ??



  • Hello,

    I would like to use the MyMessage set on the fly functions.
    Here is a dummy sketch that cannot compile.

    #include <MyMessage.h>
    
    MyMessage msgOut();
    
    void setup() {
    msgOut.setDestination(10);
    }
    
    void loop() {
    }
    

    here is the error I got :

    error: request for member 'setDestination' in 'msgOut', which is of non-class type 'MyMessage()'

    What it is wrong in the way I use this function ?
    Thanks



  • Hum some news :

    There are two constructors for MyMessage

    one is MyMessage::MyMessage()
    the other one is MyMessage::MyMessage(uint8_t _sensor, uint8_t _type)

    if I modify my dummy sketch like this :

    #include <MyMessage.h>
    
    MyMessage msgOut();
    MyMessage msgIn(1, V_TRIPPED);
    
    void setup() {
    msgIn.isAck();
    msgOut.isAck();
    msgOut.setDestination(10);
    msgIn.setDestination(10);
    }
    
    void loop() {
    }
    

    I get the following errors :

    In function 'void setup()':
    error: request for member 'isAck' in 'msgOut', which is of non-class type 'MyMessage()'
    error: request for member 'setDestination' in 'msgOut', which is of non-class type 'MyMessage()'

    The errors are only for msgOut that uses the first constructor.
    msgIn uses the second constructor and it works.

    Looks wierd to me. Can you explain why the simplest constructor gives errors ?

    Thanks again


  • Admin

    @shasha said:

    MyMessage msgOut();

    I think you should write like this to use the no-arg constructor:

    MyMessage msgOut;
    


  • hum you are right !!

    thank you !


Log in to reply
 

Suggested Topics

60
Online

11.4k
Users

11.1k
Topics

112.6k
Posts