I
I
Ilya Plotnikov2014-06-29 13:28:08
Arduino
Ilya Plotnikov, 2014-06-29 13:28:08

How to set multiple types for callback in C++?

I use the SimpleTimer library for arduino. The callback is void. I constantly have a need to create a crutch like

int foo() {.....}
void bar() {
    foo();
}

The code turns out to be heaped up with unnecessary constructions. In the .h file of the library, there is this line
typedef void (*timer_callback)(void);
I don't know C++ well, long searches didn't yield any results. Is it possible to specify multiple types for timer_callback?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vanyamba-electronics, 2015-01-04
@vanyamba-electronics

It is forbidden. Yes, and it's useless. The bar() function must be of type timer_callback, while the foo() function can be of any kind.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question