Skip to content
Prev Previous commit
Next Next commit
persist
  • Loading branch information
mcspr committed Jul 2, 2022
commit e7f8699a3c23917295a0642e84edc783f12f7f1e
6 changes: 5 additions & 1 deletion libraries/Ticker/src/Ticker.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,16 @@ class Ticker
private:
struct callback_ptr_t
{
// XXX undefined behaviour? fix next pr
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-function-type"
template <typename T>
callback_ptr_t(callback_with_typed_arg_t<T> func, T arg) :
func(reinterpret_cast<callback_with_arg_t>(func)),
arg(reinterpret_cast<void*>(arg))
#pragma GCC diagnostic pop
{
static_assert(sizeof(T) <= sizeof(void*), "");
static_assert(sizeof(T) <= sizeof(void*), "attach() callback argument size must be <= sizeof(void*)");
}

callback_with_arg_t func = nullptr;
Expand Down