I am currently trying to make a little robot thing using a Raspberry Pi Pico W, and I have most things working at the moment. However, I currently need to have a way to sort of schedule things, having certain periodicals at different times, etc.
The issue I have is that whenever I use the std::thread library, I get the same error message, no matter what I do.
no matching function for call to 'std::thread::thread(void (*)())'
Even with code that compiles and runs perfectly fine outside the pico environment.
For instance,
#include <iostream>
#include <thread>
using namespace std;
void myFunc() {
cout << "hello, world!" << endl;
}
int main() {
thread myThread(&myFunc);
myThread.join();
}
This code results in the error shown above.
Edit with some further information:
- This is using the Raspberry Pi Pico extension on VSCode
- This is on an M1 Mac
- SDK version is 2.1.1
std::thread myThread(myFunc);. Or use a lambda expression:std::thread myThread([]{ myFunc(); }this last option is nice for later too since you can capture data (in the []) and pass it on to the thread.&myFuncis technically the same asmyFunc.