Skip to content

Compiler warning for cast in Ticker code #6281

Closed
@Niek

Description

@Niek

Sample code:

#include <Ticker.h>

void testFn(unsigned char i) {}

void setup() {
  Ticker t;
  unsigned char i = 1;
  t.once_ms(100, testFn, i);
}

I get this warning when compiling the latest git version:

libraries/Ticker/Ticker.h: In instantiation of 'void Ticker::once_ms(uint32_t, void (*)(TArg), TArg) [with TArg = unsigned char; uint32_t = unsigned int]':

libraries/Ticker/Ticker.h:110:94: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
   _attach_ms(milliseconds, false, reinterpret_cast<callback_with_arg_t>(callback), (void*)arg);

It originates from this line of code (changed in commit 7910121):

_attach_ms(milliseconds, false, reinterpret_cast<callback_with_arg_t>(callback), (void*)arg);

It seems that it's caused by the (void*) cast in the last parameter.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions