Author Topic: Compiling error on M4 vs M0 and AVR.  (Read 8758 times)

shownet

  • NewMember
  • *
  • Posts: 3
Compiling error on M4 vs M0 and AVR.
« on: October 16, 2021, 06:21:37 PM »
I don't believe this issue is Moteino specific, but I did discover it because I'm working on two different Moteino boards.

I have 100 Moteino's (trace antenna) and 3 RFGateway (M4) gateways. I started using a library, SafeString (https://www.forward.com.au/pfod/ArduinoProgramming/SafeString/index.html) to handle string tokens and serial communication. I first wrote it with the Meteino AVR board definition, it compiles fine, but oops that's not the platform I need, I need it on the RFGateway M4. Change board definition, and now I get a slew of errors, this is the top and bottom portions:

Code: [Select]
In file included from C:\Users\micha\OneDrive\Documents\platformIO\Projects\test adafruit arduino\lib\SafeString\examples\SafeStringReader_GPS\SafeStringReader_GPS.ino:17:0:
C:\Users\micha\OneDrive\Documents\Arduino\libraries\SafeString\src/SafeStringReader.h:46:44: error: expected class-name before '{' token
 class SafeStringReader : public SafeString {
                                            ^
C:\Users\micha\OneDrive\Documents\Arduino\libraries\SafeString\src/SafeStringReader.h:49:41: error: expected ')' before '&' token
     explicit SafeStringReader(SafeString& _sfInput, size_t bufSize, char *tokenBuf, const char* _name, const char* delimiters, bool skipToDelimiterFlag = false, uint8_t echoInput = false, unsigned long timeout_mS = 0 );
                                         ^
C:\Users\micha\OneDrive\Documents\Arduino\libraries\SafeString\src/SafeStringReader.h:50:41: error: expected ')' before '&' token
     explicit SafeStringReader(SafeString& _sfInput, size_t bufSize, char *tokenBuf, const char* _name, const char delimiter, bool skipToDelimiterFlag = false, uint8_t echoInput = false, unsigned long timeout_mS = 0 );
                                         ^
C:\Users\micha\OneDrive\Documents\Arduino\libraries\SafeString\src/SafeStringReader.h:157:36: error: declaration of 'operator=' as non-function
     SafeStringReader & operator = (SafeString &rhs);
.
.
.
.
C:\Users\micha\AppData\Local\Arduino15\packages\Moteino\hardware\samd\1.6.3\cores\arduino/Print.h:84:12: note:   no known conversion for argument 1 from 'SafeStringReader' to 'double'
C:\Users\micha\AppData\Local\Arduino15\packages\Moteino\hardware\samd\1.6.3\cores\arduino/Print.h:85:12: note: candidate: size_t Print::println(const Printable&)
     size_t println(const Printable&);
            ^~~~~~~
C:\Users\micha\AppData\Local\Arduino15\packages\Moteino\hardware\samd\1.6.3\cores\arduino/Print.h:85:12: note:   no known conversion for argument 1 from 'SafeStringReader' to 'const Printable&'
C:\Users\micha\AppData\Local\Arduino15\packages\Moteino\hardware\samd\1.6.3\cores\arduino/Print.h:86:12: note: candidate: size_t Print::println()
     size_t println(void);
            ^~~~~~~
C:\Users\micha\AppData\Local\Arduino15\packages\Moteino\hardware\samd\1.6.3\cores\arduino/Print.h:86:12: note:   candidate expects 0 arguments, 1 provided
exit status 1
'sfReader_SF_INPUT' was not declared in this scope

These particular errors actually aren't from attempting to compile my code, they're from a sample sketch included in the library (sorry I can't find a link directly to it). Other samples also produced errors.

I found when I selected a randomly sampling of boards, most if not all AVR and M0 boards compiled fine, but no M4 boards would compile. Any ideas?





Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Compiling error on M4 vs M0 and AVR.
« Reply #1 on: October 18, 2021, 10:05:56 AM »
Not really, not without having the exact code you're trying to compile and all the libraries.

shownet

  • NewMember
  • *
  • Posts: 3
Re: Compiling error on M4 vs M0 and AVR.
« Reply #2 on: October 18, 2021, 10:00:09 PM »
So good news! The library author responded to an email and issued a fix shortly after. He had this to say:
"The problem is inconsistent use of the Arduino namespace in the boards core files.  No real way to tell if it is used or not until you compile."

Don't know if that's useful info or not, but passing it on.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Compiling error on M4 vs M0 and AVR.
« Reply #3 on: October 19, 2021, 08:51:51 AM »
Good to hear that.
However just based on "inconsistent use of the Arduino namespace in the boards core files" I'm not sure what action to take, if any is applicable, sounds like too general of a statement. I have not run into any similar issues with any other libraries.