-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't call function defined as (void) #4
Comments
could you please show me the relevant bits (i.e. the definition of nrfReceive) of your source code? |
Yes, surely I can. But it does not matter on mentioned code. Look at two example below, first one not working - error while compiling, second one working fine. The only difference is in the declaration of the called function (void) x (int).
|
Tasker expects the callback to be defined as void fn(int). The documentation does not explain it explicitly but all examples show that so please define your callbacks with the (int parameter) even if you didn't want to use it. Just like in the MultiBlink example:
|
Yes, I already alter my code that way. You're definitely a better coder in C/C++ than me, so please correct me if I'm wrong. |
That function will receive an int argument - Tasker is sending that just in case you needed a flag, a counter or something. It does come handy, as the examples show. You are not obliged to use that parameter's value in your function, of course. You can even declare it without a name so it will get ignored. The examples show this as well. Feel free to mail me directly, I'm going to close this issue. |
Any function defined as (void) can not be called by tasker.
Error while compiling:
error: invalid conversion from 'void ()()' to 'TaskCallback {aka void ()(int)}' [-fpermissive]
tasker.setInterval(nrfReceive, 5000)
Tasker.h: 53:6: error: initializing argument 1 of 'bool Tasker::setInterval(TaskCallback, long unsigned int, int, byte)' [-fpermissive]
bool Tasker*: setInterval(TaskCallback func, unsigned long interval, int param, byte prio)
Error compiling project sources
Seems that it is not BUG in Tasker itself, but some restrictions in C/C++
The text was updated successfully, but these errors were encountered: