ThePlaneGuy45
ThePlaneGuy45

Reputation: 113

Issue with c++ threading in a raspberry pi pico project

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:

Upvotes: -3

Views: 70

Answers (1)

ThePlaneGuy45
ThePlaneGuy45

Reputation: 113

I have found a working solution (for my needs) using the pico sdk multicore library.

As I understand it, using just the default pico SDK, you cannot use any multithreading, such as <thread> or <pthread.h>. However, the pico SDK comes with a useful library called pico/multicore.h. It allows you to use the second core.

Upvotes: 1

Related Questions