ARMmbed / mbed-os-example-filesystem

The Mbed OS file system example
https://mbed.com
Apache License 2.0
16 stars 33 forks source link

Don't require platform.callback-nontrivial #116

Closed kjbracey closed 4 years ago

kjbracey commented 4 years ago

Don't use an Event with Callback - it's non-trivial, so needs the "full" form of Callback. Callback is being switched to not support non-trivial functors by default to save ROM.

Use a reference_wrapper to a UserAllocatedEvent instead, which works fine with the trivial-only Callback.

A reference_wrapper is small enough to fit in a Callback, 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 be UserAllocatedEvent for simplicity.

(UserAllocatedEvent could be trivial, but is too big to be placed in a Callback directly in any case).

kjbracey commented 4 years ago

Replacement for #115. Only merge one of the PRs.

0xc0170 commented 4 years ago

@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).

kjbracey commented 4 years ago

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.

kjbracey commented 4 years ago

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));
0xc0170 commented 4 years ago

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

kjbracey commented 4 years ago

To master or a 6.0-beta, or 5.15?

kjbracey commented 4 years ago

Updated to Mbed OS 5.15.2