Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
11 years, 3 months ago.
Compile error 304 ("No instance of overloaded function ...) in Ticker.attach
The following program does not compile due to error 304 ("No instance of overloaded function "mbed::CallChain::add" matches the argument list") in source line _tick.attach(this, &PulseLamp::_tickFunc, _period );
What is wrong with it ? What is the correct syntax ?
Thanking in advance. Castro
#include "mbed.h" class PulseLamp { public: PulseLamp( int freq, DigitalOut *lamp ); void StartBlink (void); void StopBlink (void); private: float _period; DigitalOut *_led; Ticker _tick; void _tickFunc(void); }; PulseLamp::PulseLamp ( int freq, DigitalOut *lamp ) { _period = 1.0/freq; _led = lamp; } void PulseLamp::StartBlink() { _tick.attach(this, &PulseLamp::_tickFunc, _period ); } void PulseLamp::StopBlink() { _tick.detach(); } void PulseLamp::_tickFunc(void) { *_led = ! *_led; } DigitalOut lamp(LED1); PulseLamp pl(4, &lamp); int main() { pl.StartBlink(); wait(60); pl.StopBlink(); }
2 Answers
11 years, 3 months ago.
Hello,
thank you to chain this to the topic by Ian McCulloch. I responded there. Use older revision for now, it will be fixed in the next one. This usually happens when you have two variables named almost identically in a parameter list :-)
Regards,
0xc0170
11 years, 3 months ago.
Thanks Martin.
I am using mbed online compiler, and the standard mbed.org IDE.
The full error message is:
"No instance of overloaded function "mbed::CallChain::add" matches the argument list" in file "extras/mbed_5798e58a58b1/Ticker.h", Line: 161, Col: 1
It seems the problem is inside Ticker.h. Any sugestions to overcome or avoid it ?
I compiled it with the online compiler without problems. The error message indicates that the type of the arguments would be wrong. the 'attach' function is a template function. My initial guess was that the instance for T=PulseLamp had not been instantiated, so I would have expected _tick.attach<PulseLamp>(this, &PulseLamp::_tickFunc, _period ); to work, which it BTW also seems to do.
posted by 14 Aug 2013Thanks Weiden, but still got the same syntax error. I am using "mbed Library" revision 65:5798e58a58b1, that seems to be broken. There is an entry in the MBED Forum (http://mbed.org/forum/bugs-suggestions/topic/4503/ ) by user Ian McCulloch, thar reports the same bug.
posted by 14 Aug 2013
I just copied your code to keil and online compiler, pasted it to one of examples, both passed the compiling and the linking phase. No errors. What are you using?
posted by Martin Kojtal 13 Aug 2013