Skip to content

Commit

Permalink
Wrapped Ticker functions with #pragma disabling -Wcast-function-type
Browse files Browse the repository at this point in the history
  • Loading branch information
PilnyTomas committed Jan 5, 2023
1 parent 41a83c4 commit 160be7e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions libraries/Ticker/src/Ticker.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class Ticker
_attach_ms(milliseconds, true, reinterpret_cast<callback_with_arg_t>(callback), 0);
}

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-function-type"
template<typename TArg>
void attach(float seconds, void (*callback)(TArg), TArg arg)
{
Expand All @@ -65,6 +67,7 @@ class Ticker
uint32_t arg32 = (uint32_t)arg;
_attach_ms(milliseconds, true, reinterpret_cast<callback_with_arg_t>(callback), arg32);
}
#pragma GCC diagnostic pop

void once(float seconds, callback_t callback)
{
Expand All @@ -73,9 +76,11 @@ class Ticker

void once_ms(uint32_t milliseconds, callback_t callback)
{
_attach_ms(milliseconds, false, reinterpret_cast<callback_with_arg_t>(callback), 0);
_attach_ms(milliseconds, false, reinterpret_cast<callback_with_arg_t>(callback), 0);
}

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-function-type"
template<typename TArg>
void once(float seconds, void (*callback)(TArg), TArg arg)
{
Expand All @@ -91,11 +96,12 @@ class Ticker
uint32_t arg32 = (uint32_t)(arg);
_attach_ms(milliseconds, false, reinterpret_cast<callback_with_arg_t>(callback), arg32);
}
#pragma GCC diagnostic pop

void detach();
bool active();

protected:
protected:
void _attach_ms(uint32_t milliseconds, bool repeat, callback_with_arg_t callback, uint32_t arg);


Expand Down

0 comments on commit 160be7e

Please sign in to comment.