raspberrypi / pico-sdk

BSD 3-Clause "New" or "Revised" License
3.26k stars 838 forks source link

newlib not included in compile_commands.json for some files #1605

Open ast opened 5 months ago

ast commented 5 months ago

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)

peterharperuk commented 5 months ago

Why is your pico project using /usr/include/newlib?

ast commented 5 months ago

It's the standard C library used by pico-sdk.

For some reason Ubuntu installs the headers there. Is there a better way?

vulpes2 commented 5 months ago

Just ran into this, on a Fedora system you can set this to make clangd work:

set(CMAKE_C_STANDARD_INCLUDE_DIRECTORIES /usr/arm-none-eabi/include)