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

std::function support for SAMD #109

Closed
rueckix opened this issue Nov 29, 2020 · 2 comments
Closed

std::function support for SAMD #109

rueckix opened this issue Nov 29, 2020 · 2 comments

Comments

@rueckix
Copy link
Contributor

rueckix commented Nov 29, 2020

I found that ARDUINO_ARCH_SAMD does not imply HAS_FUNCTIONAL in group_object.h even though SAMD supports this c++11 template. I believe support for SAMD should be added here unless there is a specific reason not to.

Why would one need this?
This is quite useful when using callbacks on group objects. When modelling a device as a class, the callback is typically a non-static member function that cannot be passed as a regular function pointer.
An elegant solution is to combined std::bind with std::function to register a member function of a specific class object.

Implications
The change is simple but including STL headers conflicts with the definition of max and min macros in the arduino framework for SAMD. This should be fixed in arduino/ArduinoCore-samd#399 but not released.
Per interim, a hacky

#undef max
#undef min

is required before including STL headers.

Opinions?

@thelsing
Copy link
Owner

thelsing commented Dec 5, 2020

you could add these undefs to bits.h as (with #ifdef arduiono_samd) . We can remove them if the arduino core gets fixed. Feel free to submit a pull request.

@rueckix
Copy link
Contributor Author

rueckix commented Dec 6, 2020

PR open

@rueckix rueckix closed this as completed Dec 6, 2020
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

2 participants