Syntax for Libraries?

Started by stephe, June 02, 2016, 09:16:42 PM

syrinxtech

DonpK,

I'm not sure I understand your question.  Syntactically, you cannot have a unmatched set of ()'s.  If you look at what TomWS posted:

radio.sendWithRetry(uint8_t toAddress, const void* buffer, uint8_t bufferSize, uint8_t retries=2, uint8_t retryWaitTime=40);

There is only a single open and closed parenthesis.  The last two arguments are optional, with default values assigned.  The rest of the "normal" code in such a call is simply casting variables to a particular type so the compiler doesn't object.  But, you always have to have a matching "(" and ")" or you will get a compiler error.

DonpK

syrinxtech

This function with the "extra" parenthesis,
if (radio.sendWithRetry(GATEWAYID, (const void*)(&theData), sizeof(theData)))

is on line 123 of the  Struct_send.ino RFM69 example on GitHub. This is the syntax I didn't understand.

sparky

The last 2 parenthesis are to close the open parenthesis in front of radio and GATEWAYID

if (radio.sendWithRetry(GATEWAYID, (const void*)(&theData), sizeof(theData)))

  ^                             ^                                                                               ^^


DonpK