Search code examples
cstm32microcontrollerneovimclangd

stdio.h and FPU errors in Neovim using clangd LSP


I have a stm32f103 project that is initialized using stm32cubemx and I'm using neovim for editing and arm-none-eabi-gcc for compilation of code (whit auto-generated makefile).

I also have installed clangd LSP and also bear to generate compile_commands.json file. Everyting works fine except that there's two errors:

  1. stdio.h file not found
  2. Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)

I looked at core_cm3.h file and __FPU_USED is disabled, which is exactly what clang says.

/** __FPU_USED indicates whether an FPU is used or not.
    This core does not support an FPU at all
*/
#define __FPU_USED       0U

But I couldn't find any line in my makefile flags that enables the FPU for compilation.

# fpu
# NONE for Cortex-M0/M0+/M3

# float-abi


# mcu
MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)

I also commented out $(FPU) and $(FLOAT-ABI), but the error still exists. Although I can compile the project without any problems (because gcc has no complaints), but these errors are kind of on my nerve.

Is there a way to fix these errors? Or is there any gcc-based LSPs to use instead of clangd?

There's also ccls on neovim's LSP list but I was unable to install it.


Solution

  • s there a way to fix these errors?

    https://clangd.llvm.org/config#files You can:

    • create clangd configuration file
    • specify -sysroot command to specify the location of your buildchain (/usr/arm-none-eabi/ on my system)
    • and other needed options (-isysroot -nostdlib etc.) if you use them.

    I would advise anyway to move CMake and generate compile_command.json anyway.

    is there any gcc-based LSPs to use instead of clangd?

    I am not aware of any.