C++ support for std::thread #1901
Labels
No labels
bazel
bluetooth
board settings
boot_stage2
bug
build
c++
can't reproduce
clang
clib-interface
cmsis
code cleanliness
code size
compiler version issues
cyw43_driver
debug
discussion
documentation
duplicate
dynamic_clock
elf2uf2
enhancement
errata
filesystem
flash layout
floating point
FreeRTOS
hardware_adc
hardware_claim
hardware_clocks
hardware_dma
hardware_exception
hardware_flash
hardware_gpio
hardware_i2c
hardware_irq
hardware_pio
hardware_pwm
hardware_rcp
hardware_rtc
hardware_spi
hardware_sync
hardware_uart
hardware_vreg
hardware_watchdog
hardware_xosc
help wanted
host
IAR
installation
invalid
linker scripts
lto
lwip
mbedtls
missing API
needs reporter detail
networking
newlib
newlib-multicore
non-c
non-cmake
non-gcc
openocd
orphan PR
OS integration
pico_async_context
pico_base
pico_binary_info
pico_flash
picolibc
pico_lwip
pico_malloc
pico_multicore
pico_printf
pico_runtime
pico_stdio
pico_stdio_usb
pico_sync
pico_time
pico_util
pioasm
port
question
review
review2
rtos interop
runtime init
static library
svd
test
tinyusb
vscode
wifi integration
wontfix
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-raspberrypi/pico-sdk#1901
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi, I have some code built for Linux and ESP32 which use the C++ classes which wrap pthread and others. I want to use this code on a RP2040 in FreeRTOS SMP.
I added
Lab-Project-FreeRTOS-POSIXinclude and source files and can confirm the pthreads functions work.std::threadthings however do not compile. (confirming#include <thread>is there)The error when I try to declare one is:
When I try to straight up use one, eg.
the error is
So it really looks like it doesn't want to see it!
In Linux environments, the magic
-pthreadoption turns the multithreading lights on, but I guess that's not the right approach here.I have half a day into this now, and have been having the "almost there" feeling for the whole time. I started delving into the source code for std::thread and quickly realized I was in over my head. So I think it's time to ask for help.
Is there something simple I can add / define in
FreeRTOSConfig.h,CMakeLists.txtor anywhere else to magically turn the lights on?I'm happy to make a minimal example and dump code in here, but I'm kinda hoping there's a "Oh! You have to define XXXX to make it work" answer.
If it is easy / obvious, it seems to me that allowing this as a pico option somewhere would be really great and would unlock a lot of C++ compatibility.
Unfortunately there's no easy answer for this one. Most of the C++ standard library isn't available for embedded targets. See the difference between libstdc++ "freestanding" versus "hosted" mode.
Embedded toolchains come with freestanding because it's the subset of the standard library which can made available without an operating system. The rest of the standard library requires dynamic allocation, exceptions, threading support, etc. Someone would have to implement the C++ standard library for FreeRTOS.
This is so much larger than a pico-sdk issue.
The same goes for #2557