newlib not included in compile_commands.json for some files #1605
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#1605
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?
I generated a cpp project named keyboard with pico-project-generator.
Using cmake 3.27.4 with
set(CMAKE_EXPORT_COMPILE_COMMANDS ON), to generate a compile_commands.json for use with clangd (in my case with eglot on emacs).
For the file `keyboard.cpp -I/usr/include/newlib is missing, but it's there for other files such is irq_handler_chain.S and most if not all other .S files.
This causes code completion not to work correctly.
I have been unable to find the cause of this, but worked around it using:
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES /usr/include/newlib)Why is your pico project using /usr/include/newlib?
It's the standard C library used by pico-sdk.
For some reason Ubuntu installs the headers there. Is there a better way?
Just ran into this, on a Fedora system you can set this to make clangd work:
There have been some changes to the way newlib is included in SDK 2.0.0, so could you try with the new SDK and see if this is still an issue?
Nothing has changed so far. Without
set(CMAKE_C_STANDARD_INCLUDE_DIRECTORIES /usr/arm-none-eabi/include)things likestdio.hstill cannot be found. Tested with the latest version ofpico-sdkandpico-examples.Looking at the clangd docs, the best way to get it working seems to be to specify
--query-driveron the command line with the path to your compiler, rather than specifying system include paths manually (https://clangd.llvm.org/troubleshooting#cant-find-standard-library-headers-map-stdioh-etc)This works with pico examples, by generating compile_commands.json, and then running
for example - it now picks up the newlib headers correctly
The
--query-driverargument is documented hereClosing this, as I don't think the newlib libraries should be included in
compile_commands.json- instead the intellisense tool used (egclangd) should query the compiler for the system library locations