You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’m working with Raspberry Pi Pico W’s on PlatformIO and my development environment is capable of building C++23 code. It has ARDUINO_ARCH_RP2040 defined and the __cplusplus expands to 202100L.
The problem
The documentation instructs to define _TASK_STD_FUNCTION in order to enable the support for std::function callbacks. However, defining it produces an error on my environment because of this microcontroller limitation.
It might be more prudent to use the __cplusplus and __has_cpp_attribute for the C++ feature detection, instead of endlessly expanding the whitelist for future devices.
My temporary solution
The code works flawlessly with #define ARDUINO_ARCH_STM32.
// TaskScheduler.cpp// Written on January 28, February 12, 24, March 2, 4, 7, 9–11, and 16, 2024.////////////////////////////////////// 80 //////////////////////////////////////
module;
#define_TASK_SLEEP_ON_IDLE_RUN
#define_TASK_STD_FUNCTION// Enable the support for “std::function” callbacks.
#defineARDUINO_ARCH_STM32// Disguising as an STM32 microcontroller// to suppress the “Support for std::function// only for ESP8266 or ESP32 architecture” error.
#include<TaskScheduler.h>// Task, Scheduler, TASK_IMMEDIATE, TASK_FOREVER.
#undef ARDUINO_ARCH_STM32
export module TaskScheduler;
exportnamespaceTaskScheduler {
inlineconstexprunsignedlongint immediate{TASK_IMMEDIATE};
inlineconstexprlongint forever{TASK_FOREVER};
using Task = ::Task;
::Scheduler scheduler;
inlineboolexecute(void) {
// “true” if it has called a task callback.return !(TaskScheduler::scheduler.execute());
}
};
The text was updated successfully, but these errors were encountered:
The development environment
I’m working with Raspberry Pi Pico W’s on PlatformIO and my development environment is capable of building C++23 code. It has
ARDUINO_ARCH_RP2040
defined and the__cplusplus
expands to202100L
.The problem
The documentation instructs to define
_TASK_STD_FUNCTION
in order to enable the support forstd::function
callbacks. However, defining it produces an error on my environment because of this microcontroller limitation.TaskScheduler/src/TaskScheduler.h
Lines 285 to 290 in 4ccca1a
Why
std::function
callbacks are neededThis is necessary to call non-static class methods.
My suggestion
It’s all about
std::function
.TaskScheduler/src/TaskSchedulerDeclarations.h
Lines 125 to 134 in 4ccca1a
It might be more prudent to use the
__cplusplus
and__has_cpp_attribute
for the C++ feature detection, instead of endlessly expanding the whitelist for future devices.My temporary solution
The code works flawlessly with
#define ARDUINO_ARCH_STM32
.The text was updated successfully, but these errors were encountered: