The following demo program or any other program which uses the same thread start call construction will not compile in the online ide
The call follows the syntax of the current online documentation for the mbed-os Thread class
#include "mbed.h"
#include "Thread.h"
#include "Callback.h"
DigitalOut led1(LED1);
#define mySignal 0x01
void myWorker(void const* args)
{
MyTest* t = (MyTest*)args;
int i;
i++;
osSignalSet(t->_id, mySignal);
}
class MyTest
{
public:
osThreadId _id;
Thread _thread;
MyTest(osThreadId id) :
_id(id),
_thread()
{
osStatus status = _thread.start(this, &MyTest::myWorker);
// _thread.start(mbed::Callback<void>(this, &Test::myWorker));
}
};
// main() runs in its own thread in the OS
// (note the calls to Thread::wait below for delays)
int main() {
osThreadId id = Thread::gettid();
MyTest* test = new MyTest(id);
while (true) {
led1 = !led1;
Thread::wait(500);
}
}
The compiler outputs the following warning and error messages during the build
Warning: Function "rtos::Thread::start(T *, M) [with T=MyTest, M=void (MyTest::*)(const void *)]" (declared at <a href="#" onmousedown="mbed_doc_goto('/mbed-os-Thread_Testextras/mbed-os.lib/rtos/Thread.h', '214'); return false;">/extras/mbed-os.lib/rtos/Thread.h:214</a>) was declared deprecated ("The start function does not support cv-qualifiers. Replaced by thread.start(callback(obj, method)). [since mbed-os-5.1]") in "main.cpp", Line: 26, Col: 34
Error: No instance of overloaded function "rtos::Thread::start" matches the argument list in "extras/mbed-os.lib/rtos/Thread.h", Line: 215, Col: 17
Changing the call from Thread.start( .... to Thread.start(callback(....
eliminates the warning message and changes the error message to
Error: No instance of overloaded function "rtos::Thread::start" matches the argument list in "main.cpp", Line: 27, Col: 36
Changing the call from Thread.start( .... to Thread.start(Callback::Callback(.... or Thread.start(mbed:::Callback<MyTest*>(...
generated the following error
Error: Incomplete type is not allowed in "MyTest.cpp", Line: 18, Col: 39
The following demo program or any other program which uses the same thread start call construction will not compile in the online ide The call follows the syntax of the current online documentation for the mbed-os Thread class
The compiler outputs the following warning and error messages during the build
Warning: Function "rtos::Thread::start(T *, M) [with T=MyTest, M=void (MyTest::*)(const void *)]" (declared at <a href="#" onmousedown="mbed_doc_goto('/mbed-os-Thread_Testextras/mbed-os.lib/rtos/Thread.h', '214'); return false;">/extras/mbed-os.lib/rtos/Thread.h:214</a>) was declared deprecated ("The start function does not support cv-qualifiers. Replaced by thread.start(callback(obj, method)). [since mbed-os-5.1]") in "main.cpp", Line: 26, Col: 34
Error: No instance of overloaded function "rtos::Thread::start" matches the argument list in "extras/mbed-os.lib/rtos/Thread.h", Line: 215, Col: 17
Changing the call from Thread.start( .... to Thread.start(callback(....
eliminates the warning message and changes the error message to Error: No instance of overloaded function "rtos::Thread::start" matches the argument list in "main.cpp", Line: 27, Col: 36
Changing the call from Thread.start( .... to Thread.start(Callback::Callback(.... or Thread.start(mbed:::Callback<MyTest*>(... generated the following error Error: Incomplete type is not allowed in "MyTest.cpp", Line: 18, Col: 39