energia / Energia

Fork of Arduino for the Texas Instruments LaunchPad's
http://energia.nu
Other
794 stars 672 forks source link

boards from MSP430 family and blynk lib - compilation error on template #785

Closed reaper7 closed 8 years ago

reaper7 commented 8 years ago

when I try to compile examples from blynk library then I get error:

...\libraries\blynk-library/utility/BlynkUtility.h:26:20: error: expected ')' before numeric constant
...\libraries\blynk-library/utility/BlynkUtility.h:26:20: error: expected '>' before numeric constant
...\libraries\blynk-library/utility/BlynkUtility.h:26:20: error: expected unqualified-id before ')' token

26 line from BlynkUtility looks:

26  template <unsigned N, typename T>
27  void BlynkAverageSample (T& avg, const T& input) {
28      avg -= avg/N;
29      const T add = input/N;
30      // Fix for shorter delays
31      avg += (add > 0) ? add : -1;
32  }

the same code compiled OK on other Energia platforms CC3200/Stallaris/Tiva and Arduino/ESP8266

...this is compilator error? or maybe incorrect wrote template on blynk library ?

rei-vilo commented 8 years ago

Try and rename the variables N and T to NN and TT.

The former names may conflict with macros.

Which MSP430 board are you compiling against?

reaper7 commented 8 years ago

LOL - it works... :D tnx!

BTW still get one more error:

User_Defined_Connection.cpp: In function 'size_t BlynkStreamRead(void*, size_t)':
User_Defined_Connection.cpp:42:42: error: invalid conversion from 'byte* {aka unsigned char*}' to 'char*' [-fpermissive]
C:\PROGRAMY\energia\hardware\msp430\cores\msp430/Stream.h:76:10: error:   initializing argument 1 of 'size_t Stream::readBytes(char*, size_t)' [-fpermissive]
rei-vilo commented 8 years ago
reaper7 commented 8 years ago

I rename T & N and error is gone:

template <unsigned NN, typename TT>
void BlynkAverageSample (TT& avg, const TT& input) {
    avg -= avg/NN;
    const TT add = input/NN;
    // Fix for shorter delays
    avg += (add > 0) ? add : -1;
}

I'm try on msp430f5529 and msp430g2955

EDIT: changing T is not neccesary, need only N to NN

rei-vilo commented 8 years ago

Please report the issue and suggest the solution to Blynk! Thank you.

reaper7 commented 8 years ago

of course I report

what You mean: "Use transtype function to convert byte* to char*."

rei-vilo commented 8 years ago

With the following declarations

reaper7 commented 8 years ago

sorry but second problem is gone :) maybe energia restart was needed.

finally: rename N to NN solves problem tnx rei-vilo