Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SafeString won't compile on SOME SAMD21 boards, works on others #73

Closed
mgrusin opened this issue May 22, 2024 · 4 comments
Closed

SafeString won't compile on SOME SAMD21 boards, works on others #73

mgrusin opened this issue May 22, 2024 · 4 comments

Comments

@mgrusin
Copy link

mgrusin commented May 22, 2024

Hi, I've had this problem for a while but ran into it again today so finally decided to ask:

Safestring always compiles properly for the Arduino MKR Zero board definition.

It has fatal compilation errors on (so far), Sparkfun's SAMD21 boards ("SAMD21 Dev Breakout"), and Adafruit's Feather M0 ("Basic").

These boards all use the same MPU and are electrically similar so this "must" be coming from something in the board support package(s). (Quotes because I know errors come from strange places...)

I'm using the latest Arduino IDE (2.3.2) and Safestring library (4.1.31).

The first error when compiling is:

In file included from C:\Users\mgrus\Documents\Arduino\VGM-A390-1_V10\VGM-A390-1_V10.ino:99: c:\Users\mgrus\Documents\Arduino\libraries\SafeString\src/SafeStringReader.h:73:44: error: expected class-name before '{' token 73 | class SafeStringReader : public SafeString { | ^

I can sort of work around this by forcing the MKR Zero definition, but then I have to manually figure out and translate the Arduino port numbers because people wire their boards differently. This is inconvenient but works.

Any quick suggestions / something I'm doing wrong? I really like the Safestring library and would love including it to be painless.

Thanks so much! -Mike

@PowerBroker2
Copy link
Owner

@drmpf

@drmpf
Copy link
Collaborator

drmpf commented May 23, 2024

The problem is namespace arduino.
The Arduino boards need this, while Adafruit and Sparkfun SAMD board support don't need it and the compile fails if it is used.

The three files
SafeStringNameSpace.h
SafeStringNameSpaceEnd.h
SafeStringNameSpaceStart.h

handle arduino namespace usage.

BUT in the current release ALL boards that define ARDUINO_ARCH_SAMD for compiles are assumed to use arduino namespace
Adafruit and Sparkfun SAMD boards have this define and so are failing.

Adafruit has a ARDUINO_SAMD_ADAFRUIT define which I can use to fix this for Adafruit boards
BUT Sparkfun has not supplied any unique define to test so I can tell SafeString is being compiled for a Sparkfun SAMD board as opposed to an Arduino SAMD board

I will fix the code to look for ARDUINO_SAMD_ADAFRUIT but no 'general' fix available, at the moment, for Sparkfun SAMD boards.

Your immediate fix for non-Arduino SAMD boards, is to remove all the contents of those three .h file. I.e. just have three empty files.

In the longer term, after the above fix is made, either Sparkfun will provide a define to use
OR
you will have to add -DARDUINO_SAMD_ADAFRUIT to the compile patterns in Sparkfun's platform.txt file for the SAMD boards
OR
have special version of the SaftString library for Sparkfun SAMD boards with empty SaftStringNameSpace....h files

@drmpf
Copy link
Collaborator

drmpf commented May 24, 2024

V4.1.32 implements fix for Adafruit SAMD boards

1 similar comment
@drmpf
Copy link
Collaborator

drmpf commented Jun 26, 2024

V4.1.32 implements fix for Adafruit SAMD boards

@drmpf drmpf closed this as completed Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants