Closed kjbracey closed 4 years ago
Replacement for #115. Only merge one of the PRs.
@kjbracey-arm Just to confirm - travis failures are expected as Mbed OS PR not yet integrated. So the proposal steps will be to merge this one, merge Mbed OS PR (it will test this example so if passes we are all ok).
Actually, both this and #115 should be passing with current master, they don't depend on the PR.
But they're prerequisites to the PR passing.
Hmm, error indicates the CI here is not being built as C++11. Eh? Really old Mbed OS?
[ERROR] ./main.cpp:72:8: warning: 'auto' changes meaning in C++11; please remove it [-Wc++11-compat]
static auto erase_event = mbed_event_queue()->make_user_allocated_event(erase);
^~~~
./main.cpp:72:13: error: 'erase_event' does not name a type; did you mean 'equeue_event'?
static auto erase_event = mbed_event_queue()->make_user_allocated_event(erase);
^~~~~~~~~~~
equeue_event
./main.cpp: In function 'int main()':
./main.cpp:80:19: error: 'ref' is not a member of 'std'
irq.fall(std::ref(erase_event));
^~~
./main.cpp:80:23: error: 'erase_event' was not declared in this scope
irq.fall(std::ref(erase_event));
^~~~~~~~~~~
./main.cpp:80:23: note: suggested alternative: 'equeue_event'
irq.fall(std::ref(erase_event));
yes, master points to very old sha: https://github.com/ARMmbed/mbed-os-example-filesystem/blob/master/mbed-os.lib , update in this PR to resolve it
To master or a 6.0-beta, or 5.15?
Updated to Mbed OS 5.15.2
Don't use an
Event
withCallback
- it's non-trivial, so needs the "full" form ofCallback
.Callback
is being switched to not support non-trivial functors by default to save ROM.Use a
reference_wrapper
to aUserAllocatedEvent
instead, which works fine with the trivial-onlyCallback
.A
reference_wrapper
is small enough to fit in aCallback
, and is trivially-copyable, so works to decouple the event lifetime from the callback. Having decoupled it, the event has program lifetime, so may as well beUserAllocatedEvent
for simplicity.(
UserAllocatedEvent
could be trivial, but is too big to be placed in aCallback
directly in any case).