clangd / clangd

clangd language server
https://clangd.llvm.org
Apache License 2.0
1.5k stars 63 forks source link

Add a clangd.fallbackCommand or extend compile_commands.json to support more complex scenarios. #784

Open Falven opened 3 years ago

Falven commented 3 years ago

If clangd can't find a compilation command in the compilation database, as is common for, say, header files included in your source files, it will fallback to calling the clang executable along with any flags you define in clangd.fallbackFlags. However, this does not support cross compilation scenarios. I need to be able to specify the clangd.fallbackCommand.

I think another, better, way to address this would be to modify compile_commands.json to allow "fallback" commands that work for all files and other commands can extend. This would actually simplify compile_commands.json as well, such that you don't have to repeat arguments to each file you would like to compile.

Example: Before:

[
  {
    "directory": "c:\\Users\\falve\\.vscode\\extensions\\vsciot-vscode.vscode-arduino-0.4.3\\out\\src",
    "arguments": [
      "C:\\Users\\falve\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\7-2017q4/bin/arm-none-eabi-g++.exe",
      "-mcpu=cortex-m0plus",
      "-mthumb",
      "-c",
      "-g",
      "-Os",
      "-w",
      "-std=gnu++11",
      "-ffunction-sections",
      "-fdata-sections",
      "-fno-threadsafe-statics",
      "-nostdlib",
      "--param",
      "max-inline-insns-single=500",
      "-fno-rtti",
      "-fno-exceptions",
      "-MMD",
      "-DF_CPU=48000000L",
      "-DARDUINO=10607",
      "-DARDUINO_SAMD_MKRWIFI1010",
      "-DARDUINO_ARCH_SAMD",
      "-DUSE_ARDUINO_MKR_PIN_LAYOUT",
      "-D__SAMD21G18A__",
      "-DUSB_VID=0x2341",
      "-DUSB_PID=0x8054",
      "-DUSBCON",
      "-DUSB_MANUFACTURER=\"Arduino LLC\"",
      "-DUSB_PRODUCT=\"Arduino MKR WiFi 1010\"",
      "-DUSE_BQ24195L_PMIC",
      "-IC:\\Users\\falve\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\CMSIS\\4.5.0/CMSIS/Include/",
      "-IC:\\Users\\falve\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\CMSIS-Atmel\\1.2.0/CMSIS/Device/ATMEL/",
      "-IC:\\Users\\falve\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\samd\\1.8.11\\cores\\arduino/api/deprecated",
      "-IC:\\Users\\falve\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\samd\\1.8.11\\cores\\arduino/api/deprecated-avr-comp",
      "-IC:\\Users\\falve\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\samd\\1.8.11\\cores\\arduino",
      "-IC:\\Users\\falve\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\samd\\1.8.11\\variants\\mkrwifi1010",
      "c:\\source\\repos\\clangd-arduino\\build\\sketch\\clangd-arduino.ino.cpp",
      "-o",
      "c:\\source\\repos\\clangd-arduino\\build\\sketch\\clangd-arduino.ino.cpp.o"
    ],
    "file": "c:\\source\\repos\\clangd-arduino\\build\\sketch\\clangd-arduino.ino.cpp"
  },
  {
    "directory": "c:\\Users\\falve\\.vscode\\extensions\\vsciot-vscode.vscode-arduino-0.4.3\\out\\src",
    "arguments": [
      "C:\\Users\\falve\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\7-2017q4/bin/arm-none-eabi-g++.exe",
      "-mcpu=cortex-m0plus",
      "-mthumb",
      "-c",
      "-g",
      "-Os",
      "-w",
      "-std=gnu++11",
      "-ffunction-sections",
      "-fdata-sections",
      "-fno-threadsafe-statics",
      "-nostdlib",
      "--param",
      "max-inline-insns-single=500",
      "-fno-rtti",
      "-fno-exceptions",
      "-MMD",
      "-DF_CPU=48000000L",
      "-DARDUINO=10607",
      "-DARDUINO_SAMD_MKRWIFI1010",
      "-DARDUINO_ARCH_SAMD",
      "-DUSE_ARDUINO_MKR_PIN_LAYOUT",
      "-D__SAMD21G18A__",
      "-DUSB_VID=0x2341",
      "-DUSB_PID=0x8054",
      "-DUSBCON",
      "-DUSB_MANUFACTURER=\"Arduino LLC\"",
      "-DUSB_PRODUCT=\"Arduino MKR WiFi 1010\"",
      "-DUSE_BQ24195L_PMIC",
      "-IC:\\Users\\falve\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\CMSIS\\4.5.0/CMSIS/Include/",
      "-IC:\\Users\\falve\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\CMSIS-Atmel\\1.2.0/CMSIS/Device/ATMEL/",
      "-IC:\\Users\\falve\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\samd\\1.8.11\\cores\\arduino/api/deprecated",
      "-IC:\\Users\\falve\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\samd\\1.8.11\\cores\\arduino/api/deprecated-avr-comp",
      "-IC:\\Users\\falve\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\samd\\1.8.11\\cores\\arduino",
      "-IC:\\Users\\falve\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\samd\\1.8.11\\variants\\mkrwifi1010",
      "C:\\Users\\falve\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\samd\\1.8.11\\variants\\mkrwifi1010\\variant.cpp",
      "-o",
      "c:\\source\\repos\\clangd-arduino\\build\\core\\variant.cpp.o"
    ],
    "file": "C:\\Users\\falve\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\samd\\1.8.11\\variants\\mkrwifi1010\\variant.cpp"
  }
]

After:

[
  {
    "name": "fallback",
    "directory": "c:\\Users\\falve\\.vscode\\extensions\\vsciot-vscode.vscode-arduino-0.4.3\\out\\src",
    "command": "C:\\Users\\falve\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\7-2017q4/bin/arm-none-eabi-g++.exe",
    "arguments": [
      "-mcpu=cortex-m0plus",
      "-mthumb",
      "-g",
      "-Os",
      "-w",
      "-std=gnu++11",
      "-ffunction-sections",
      "-fdata-sections",
      "-fno-threadsafe-statics",
      "-nostdlib",
      "--param",
      "max-inline-insns-single=500",
      "-fno-rtti",
      "-fno-exceptions",
      "-MMD",
      "-DF_CPU=48000000L",
      "-DARDUINO=10607",
      "-DARDUINO_SAMD_MKRWIFI1010",
      "-DARDUINO_ARCH_SAMD",
      "-DUSE_ARDUINO_MKR_PIN_LAYOUT",
      "-D__SAMD21G18A__",
      "-DUSB_VID=0x2341",
      "-DUSB_PID=0x8054",
      "-DUSBCON",
      "-DUSB_MANUFACTURER=\"Arduino LLC\"",
      "-DUSB_PRODUCT=\"Arduino MKR WiFi 1010\"",
      "-DUSE_BQ24195L_PMIC",
      "-IC:\\Users\\falve\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\CMSIS\\4.5.0/CMSIS/Include/",
      "-IC:\\Users\\falve\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\CMSIS-Atmel\\1.2.0/CMSIS/Device/ATMEL/",
      "-IC:\\Users\\falve\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\samd\\1.8.11\\cores\\arduino/api/deprecated",
      "-IC:\\Users\\falve\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\samd\\1.8.11\\cores\\arduino/api/deprecated-avr-comp",
      "-IC:\\Users\\falve\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\samd\\1.8.11\\cores\\arduino",
      "-IC:\\Users\\falve\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\samd\\1.8.11\\variants\\mkrwifi1010"
    ]
  },
  {
    "name": "clangd_arduino",
    "command": "${fallback.command}",
    "arguments": [
      "${fallback.arguments}",
      "-c",
      "c:\\source\\repos\\clangd-arduino\\build\\sketch\\clangd-arduino.ino.cpp",
      "-o",
      "c:\\source\\repos\\clangd-arduino\\build\\sketch\\clangd-arduino.ino.cpp.o"
    ],
    "file": "c:\\source\\repos\\clangd-arduino\\build\\sketch\\clangd-arduino.ino.cpp"
  },
  {
    "name": "variant",
    "command": "${fallback.command}",
    "arguments": [
      "${fallback.arguments}",
      "-c",
      "C:\\Users\\falve\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\samd\\1.8.11\\variants\\mkrwifi1010\\variant.cpp",
      "-o",
      "c:\\source\\repos\\clangd-arduino\\build\\core\\variant.cpp.o"
    ],
    "file": "C:\\Users\\falve\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\samd\\1.8.11\\variants\\mkrwifi1010\\variant.cpp"
  }
]

Granted this example was contrived rather quickly.

Logs

I[18:58:14.272] Failed to find compilation database for c:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino\Arduino.h
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\Llvm\bin\clang -xobjective-c++-header c:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino\Arduino.h -fsyntax-only -resource-dir=c:\Users\falve\AppData\Roaming\Code\User\globalStorage\llvm-vs-code-extensions.vscode-clangd\install\12.0.0\clangd_12.0.0\lib\clang\12.0.0

System information PS C:\source\repos\clangd-arduino> clangd --version clangd version 11.0.0 Editor/LSP plugin: VS Code Operating system: Windows 10

Falven commented 3 years ago

Just saw this thread. I think adding the --compile-commands-dir= partially solves the issue, however, when analyzing a cpp file that includes a header for a compilation unit not in your compilation database, clangd seems to still try to compile it with clang and fallback arguments as the intellisense errors that are produced seem consistent with that.

I think we need a better solution here, clearly this affects a lot of end-users.

HighCommander4 commented 3 years ago

Just saw this thread. I think adding the --compile-commands-dir= partially solves the issue,

Yep, I would recommend using that. You can also do it using config as described here.

however, when analyzing a cpp file that includes a header for a compilation unit not in your compilation database, clangd seems to still try to compile it with clang and fallback arguments

I'm not following this part. A command applies to the whole translation unit, so if you open a cpp file, the contents of the entire translation unit (including all included headers) are analyzed using the same command.

If you open a header file, the header file is analyzed as its own translation unit, but if you're using --compile-commands-dir, clangd should still find a command from the database to get flags for it.

Falven commented 3 years ago

Just saw this thread. I think adding the --compile-commands-dir= partially solves the issue,

Yep, I would recommend using that. You can also do it using config as described here.

Using a project config won't work for my scenario, because the file in question, Arduino.h, is not a part of the project, so clangd will never find the configuration as it searches in parent directories of the Arduino.h file. Using a user-level config doesn't seem like a good solution either as this particular configuration is project-specific. However, as I mentioned, using the argument "--compile-commands-dir=${workspaceFolder}\\build", in my VS Code workspace settings seems to work. It allows clangd to infer the correct compilation command when navigating to Arduino.h.

That is a very subtle change to get compilation command inference working. I think it should be enabled by default, as long as clangd finds a CDB. If not, then at a minimum all of the ways to configure this should be documented in clangd configuration page.

however, when analyzing a cpp file that includes a header for a compilation unit not in your compilation database, clangd seems to still try to compile it with clang and fallback arguments

I'm not following this part. A command applies to the whole translation unit, so if you open a cpp file, the contents of the entire translation unit (including all included headers) are analyzed using the same command.

If you open a header file, the header file is analyzed as its own translation unit, but if you're using --compile-commands-dir, clangd should still find a command from the database to get flags for it.

Maybe this is a bug or a false-positive, but that does not seem to be what I am observing. I am observing a large mismatch between clangd output and the compiler output.

Given the following file:

clangd-arduino.ino ```cpp #include #include void setup() { std::string testing("Testing... "); } void loop() {} ```

clangd will correctly infer the following compilation command from the CDB:

Compilation command created by clangd ```shell C:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\arm-none-eabi-g++.exe --target=arm-none-eabi --driver-mode=g++ -mcpu=cortex-m0plus -mthumb -c -g -Os -w -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DF_CPU=48000000L -DARDUINO=10607 -DARDUINO_SAMD_MKRWIFI1010 -DARDUINO_ARCH_SAMD -DUSE_ARDUINO_MKR_PIN_LAYOUT -D__SAMD21G18A__ -DUSB_VID=0x2341 -DUSB_PID=0x8054 -DUSBCON -DUSB_MANUFACTURER="Arduino LLC" -DUSB_PRODUCT="Arduino MKR WiFi 1010" -DUSE_BQ24195L_PMIC -IC:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0/CMSIS/Include/ -IC:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/ -IC:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino/api/deprecated -IC:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino/api/deprecated-avr-comp -IC:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino -IC:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\variants\mkrwifi1010 -x c++-header -std=gnu++11 c:\source\repos\clangd-arduino\clangd-arduino.ino -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1 -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/arm-none-eabi -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/backward -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include-fixed -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include -fsyntax-only -resource-dir=c:\Users\falve\AppData\Roaming\Code\User\globalStorage\llvm-vs-code-extensions.vscode-clangd\install\12.0.0\clangd_12.0.0\lib\clang\12.0.0 ```

If we remove the --target=arm-none-eabi --driver-mode=g++ -resource-dir= flags, add --verbose and execute this compilation command in the terminal, we get no errors, warnings, or diagnostics; indicating a successful compilation:

Compilation command output from the terminal ```shell Using built-in specs. COLLECT_GCC=C:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\arm-none-eabi-g++.exe Target: arm-none-eabi Configured with: /mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/src/gcc/configure --build=x86_64-linux-gnu --host=i686-w64-mingw32 --target=arm-none-eabi --prefix=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/install-mingw --libexecdir=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/install-mingw/lib --infodir=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/install-mingw/share/doc/gcc-arm-none-eabi/info --mandir=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/install-mingw/share/doc/gcc-arm-none-eabi/man --htmldir=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/install-mingw/share/doc/gcc-arm-none-eabi/html --pdfdir=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/install-mingw/share/doc/gcc-arm-none-eabi/pdf --enable-languages=c,c++ --enable-mingw-wildcard --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-tls --with-gnu-as --with-gnu-ld --with-headers=yes --with-newlib --with-python-dir=share/gcc-arm-none-eabi --with-sysroot=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/install-mingw/arm-none-eabi --with-libiconv-prefix=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/build-mingw/host-libs/usr --with-gmp=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/build-mingw/host-libs/usr --with-mpfr=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/build-mingw/host-libs/usr --with-mpc=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/build-mingw/host-libs/usr --with-isl=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/build-mingw/host-libs/usr --with-libelf=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/build-mingw/host-libs/usr --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-pkgversion='GNU Arm Embedded Toolchain 10-2020-q4-major' --with-multilib-list=rmprofile,aprofile Thread model: single Supported LTO compression algorithms: zlib gcc version 10.2.1 20201103 (release) (GNU Arm Embedded Toolchain 10-2020-q4-major) COLLECT_GCC_OPTIONS='-mcpu=cortex-m0plus' '-mthumb' '-c' '-g' '-Os' '-w' '-ffunction-sections' '-fdata-sections' '-fno-threadsafe-statics' '-nostdlib' '--param=max-inline-insns-single=500' '-fno-rtti' '-fno-exceptions' '-D' 'F_CPU=48000000L' '-D' 'ARDUINO=10607' '-D' 'ARDUINO_SAMD_MKRWIFI1010' '-D' 'ARDUINO_ARCH_SAMD' '-D' 'USE_ARDUINO_MKR_PIN_LAYOUT' '-D' '__SAMD21G18A__' '-D' 'USB_VID=0x2341' '-D' 'USB_PID=0x8054' '-D' 'USBCON' '-D' 'USB_MANUFACTURER=Arduino LLC' '-D' 'USB_PRODUCT=Arduino MKR WiFi 1010' '-D' 'USE_BQ24195L_PMIC' '-I' 'C:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0/CMSIS/Include/' '-I' 'C:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/' '-I' 'C:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino/api/deprecated' '-I' 'C:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino/api/deprecated-avr-comp' '-I' 'C:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino' '-I' 'C:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\variants\mkrwifi1010' '-std=gnu++11' '-isystem' 'c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1' '-isystem' 'c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/arm-none-eabi' '-isystem' 'c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/backward' '-isystem' 'c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include' '-isystem' 'c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include-fixed' '-isystem' 'c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include' '-fsyntax-only' '-v' '-mfloat-abi=soft' '-march=armv6s-m' c:/users/falve/appdata/local/arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/../lib/gcc/arm-none-eabi/10.2.1/cc1plus.exe -quiet -v -I C:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0/CMSIS/Include/ -I C:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/ -I C:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino/api/deprecated -I C:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino/api/deprecated-avr-comp -I C:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino -I C:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\variants\mkrwifi1010 -imultilib thumb/v6-m/nofp -iprefix c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/ -isysroot c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../arm-none-eabi -D__USES_INITFINI__ -D F_CPU=48000000L -D ARDUINO=10607 -D ARDUINO_SAMD_MKRWIFI1010 -D ARDUINO_ARCH_SAMD -D USE_ARDUINO_MKR_PIN_LAYOUT -D __SAMD21G18A__ -D USB_VID=0x2341 -D USB_PID=0x8054 -D USBCON -D USB_MANUFACTURER=Arduino LLC -D USB_PRODUCT=Arduino MKR WiFi 1010 -D USE_BQ24195L_PMIC -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1 -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/arm-none-eabi -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/backward -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include-fixed -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include c:\source\repos\clangd-arduino\clangd-arduino.ino -quiet -dumpbase clangd-arduino.ino -mcpu=cortex-m0plus -mthumb -mfloat-abi=soft -march=armv6s-m -auxbase clangd-arduino -g -Os -w -std=gnu++11 -version -ffunction-sections -fdata-sections -fno-threadsafe-statics -fno-rtti -fno-exceptions -fsyntax-only -o nul --param=max-inline-insns-single=500 GNU C++11 (GNU Arm Embedded Toolchain 10-2020-q4-major) version 10.2.1 20201103 (release) (arm-none-eabi) compiled by GNU C version 7.3-win32 20180312, GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.3, isl version isl-0.18-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring duplicate directory "c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1" ignoring duplicate directory "c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/backward" ignoring duplicate directory "c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include" ignoring duplicate directory "c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include-fixed" ignoring duplicate directory "c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include" ignoring duplicate directory "c:/users/falve/appdata/local/arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/lib/gcc/../../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1" ignoring duplicate directory "c:/users/falve/appdata/local/arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/lib/gcc/../../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/arm-none-eabi/thumb/v6-m/nofp" ignoring duplicate directory "c:/users/falve/appdata/local/arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/lib/gcc/../../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/backward" ignoring duplicate directory "c:/users/falve/appdata/local/arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/lib/gcc/../../lib/gcc/arm-none-eabi/10.2.1/include" ignoring nonexistent directory "c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../arm-none-eabi/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/install-mingw/lib/gcc/arm-none-eabi/10.2.1/../../../../include" ignoring duplicate directory "c:/users/falve/appdata/local/arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/lib/gcc/../../lib/gcc/arm-none-eabi/10.2.1/include-fixed" ignoring duplicate directory "c:/users/falve/appdata/local/arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/lib/gcc/../../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include" ignoring nonexistent directory "c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../arm-none-eabi/usr/include" #include "..." search starts here: #include <...> search starts here: C:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0/CMSIS/Include C:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL C:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino/api/deprecated C:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino/api/deprecated-avr-comp C:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino C:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\variants\mkrwifi1010 c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1 c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/arm-none-eabi c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/backward c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include-fixed c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/arm-none-eabi/thumb/v6-m/nofp End of search list. GNU C++11 (GNU Arm Embedded Toolchain 10-2020-q4-major) version 10.2.1 20201103 (release) (arm-none-eabi) compiled by GNU C version 7.3-win32 20180312, GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.3, isl version isl-0.18-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: a4fe51cc32557f05b9d40da079bbd1f1 COMPILER_PATH=c:/users/falve/appdata/local/arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/../lib/gcc/arm-none-eabi/10.2.1/;c:/users/falve/appdata/local/arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/../lib/gcc/;c:/users/falve/appdata/local/arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ LIBRARY_PATH=c:/users/falve/appdata/local/arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/../lib/gcc/arm-none-eabi/10.2.1/thumb/v6-m/nofp/;c:/users/falve/appdata/local/arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/;c:/users/falve/appdata/local/arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/../arm-none-eabi/lib/thumb/v6-m/nofp/;c:/users/falve/appdata/local/arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/../lib/gcc/arm-none-eabi/10.2.1/;c:/users/falve/appdata/local/arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/../lib/gcc/;c:/users/falve/appdata/local/arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/lib/;c:/users/falve/appdata/local/arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/../arm-none-eabi/lib/ COLLECT_GCC_OPTIONS='-mcpu=cortex-m0plus' '-mthumb' '-c' '-g' '-Os' '-w' '-ffunction-sections' '-fdata-sections' '-fno-threadsafe-statics' '-nostdlib' '--param=max-inline-insns-single=500' '-fno-rtti' '-fno-exceptions' '-D' 'F_CPU=48000000L' '-D' 'ARDUINO=10607' '-D' 'ARDUINO_SAMD_MKRWIFI1010' '-D' 'ARDUINO_ARCH_SAMD' '-D' 'USE_ARDUINO_MKR_PIN_LAYOUT' '-D' '__SAMD21G18A__' '-D' 'USB_VID=0x2341' '-D' 'USB_PID=0x8054' '-D' 'USBCON' '-D' 'USB_MANUFACTURER=Arduino LLC' '-D' 'USB_PRODUCT=Arduino MKR WiFi 1010' '-D' 'USE_BQ24195L_PMIC' '-I' 'C:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0/CMSIS/Include/' '-I' 'C:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/' '-I' 'C:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino/api/deprecated' '-I' 'C:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino/api/deprecated-avr-comp' '-I' 'C:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino' '-I' 'C:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\variants\mkrwifi1010' '-std=gnu++11' '-isystem' 'c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1' '-isystem' 'c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/arm-none-eabi' '-isystem' 'c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/backward' '-isystem' 'c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include' '-isystem' 'c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include-fixed' '-isystem' 'c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include' '-fsyntax-only' '-v' '-mfloat-abi=soft' '-march=armv6s-m' ```

If we take a look at the clangd output, we can see it reports using the correctly-determined compilation database and it correctly infers the compilation command:

VS Code clangd output ```shell I[08:23:54.228] Loaded compilation database from c:\source\repos\clangd-arduino\build\compile_commands.json ... I[08:23:54.682] ASTWorker building file c:\source\repos\clangd-arduino\clangd-arduino.ino version 1 with command inferred from c:\source\repos\clangd-arduino\build\sketch\clangd-arduino.ino.cpp ... V[08:23:55.600] Dropped diagnostic: c:\source\repos\clangd-arduino\clangd-arduino.ino: in included file: anonymous bit-field cannot have qualifiers ... V[08:23:55.600] Dropped diagnostic: c:\source\repos\clangd-arduino\clangd-arduino.ino: in included file: anonymous bit-field cannot have qualifiers ... ```

However, it falsely reports errors that spill over to other code in the file and make development impossible.

VS Code intellisense clangd reported errors: ```shell Too many errors emitted, stopping nowclang(fatal_too_many_errors) In included file: anonymous bit-field cannot have qualifiersclang(anon_bitfield_qualifiers) ac.h(241, 18): Error occurred here Cannot initialize a variable of type 'std::string' (aka 'int') with an lvalue of type 'const char [12]'clang(init_conversion_failed) ```

These errors that are being emitted above, to me, smell like a bug with clangd trying to compile that header with clang instead of the command used for the compilation unit. I don't know what else it could possibly be as the command clearly works in the terminal, but not when clangd executes it.

kadircet commented 3 years ago

i believe the piece missing here is the command line generated by clangd is not executed as-is it is used to create a clang compiler instance. hence the need for deleting --driver-mode or --resource-dir when invoking the command as-is, because these won't work with gcc.

as mentioned in a separate topic the diagnostic for anon bit field qualifiers is a real error for C++. You can compare https://en.cppreference.com/w/cpp/language/bit_field vs https://en.cppreference.com/w/c/language/bit_field (I know cppreference is not authoritative for the spec but it is close enough), basically this is allowed in C, but not in C++.

so unless there are some builtin macros clang is failing to infer (which is a shortcoming of custom toolchain support, if a compiler has magical builtin macros clang(d) can't really know about them and there's no good way to communicate those today), this must be an extension of gcc. We can diagnose this better if you can provide the contents from the ac.h around line 241 (as indicated by clang's error).

Falven commented 3 years ago

i believe the piece missing here is the command line generated by clangd is not executed as-is it is used to create a clang compiler instance. hence the need for deleting --driver-mode or --resource-dir when invoking the command as-is, because these won't work with gcc.

I see. I couldn't find those commands on the documentation for arm-none-eabi-g++, so that makes sense.

as mentioned in a separate topic the diagnostic for anon bit field qualifiers is a real error for C++. You can compare https://en.cppreference.com/w/cpp/language/bit_field vs https://en.cppreference.com/w/c/language/bit_field (I know cppreference is not authoritative for the spec but it is close enough), basically this is allowed in C, but not in C++.

Yes, I realize it is a real error. Obviously though, it compiles fine using arm-none-eabi-g++ so there is some bug with clangd where the cross compilation is not working correctly.

so unless there are some builtin macros clang is failing to infer (which is a shortcoming of custom toolchain support, if a compiler has magical builtin macros clang(d) can't really know about them and there's no good way to communicate those today), this must be an extension of gcc. We can diagnose this better if you can provide the contents from the ac.h around line 241 (as indicated by clang's error).

I am not an expert on this low-level stuff, to be honest, so I really appreciate all the help you can give; this is also why I am using Arduino and not developing down to the metal for SAMD 😁.

arm-none-eabi-g++ --version ```ps PS C:\Windows\System32> C:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\7- 2017q4\bin\arm-none-eabi-g++.exe --version arm-none-eabi-g++.exe (GNU Arm Embedded Toolchain 10-2020-q4-major) 10.2.1 20201103 (release) Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ```
The lines that clangd-arduino.ino:1 intellisense is complaining about are ac.h(241, 18): ```cpp 235 /* -------- AC_INTFLAG : (AC Offset: 0x06) (R/W 8) Interrupt Flag Status and Clear -------- */ 236 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 237 typedef union { // __I to avoid read-modify-write on write-to-clear register 238 struct { 239 __I uint8_t COMP0:1; /*!< bit: 0 Comparator 0 */ 240 __I uint8_t COMP1:1; /*!< bit: 1 Comparator 1 */ 241 __I uint8_t :2; /*!< bit: 2.. 3 Reserved */ 242 __I uint8_t WIN0:1; /*!< bit: 4 Window 0 */ 243 __I uint8_t :3; /*!< bit: 5.. 7 Reserved */ 244 } bit; /*!< Structure used for bit access */ 245 struct { 246 __I uint8_t COMP:2; /*!< bit: 0.. 1 Comparator x */ 247 __I uint8_t :2; /*!< bit: 2.. 3 Reserved */ 248 __I uint8_t WIN:1; /*!< bit: 4 Window x */ 249 __I uint8_t :3; /*!< bit: 5.. 7 Reserved */ 250 } vec; /*!< Structure used for vec access */ 251 uint8_t reg; /*!< Type used for register access */ 252 } AC_INTFLAG_Type; 253 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ ```
It is interesting to note that when I go to ac.h, intellisense changes and does not provide an error about ac.h(241, 18), but rather the following: | Lines | Intellisense Error | | -------------- | --------------------------------------------------------------------------- | | ac.h:1 | Too many errors emitted, stopping now clang(fatal_too_many_errors) | | ac.h:60-66 | Unknown type name 'uint8_t' clang(unknown_typename) | | ac.h:88-96 | Unknown type name 'uint8_t' clang(unknown_typename) | | ac.h:116-122 | Unknown type name 'uint16_t' clang(unknown_typename) |
ac.h:1 ```cpp /** ```
ac.h:56-68 ```cpp /* -------- AC_CTRLA : (AC Offset: 0x00) (R/W 8) Control A -------- */ #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) typedef union { struct { uint8_t SWRST:1; /*!< bit: 0 Software Reset */ uint8_t ENABLE:1; /*!< bit: 1 Enable */ uint8_t RUNSTDBY:1; /*!< bit: 2 Run in Standby */ uint8_t :4; /*!< bit: 3.. 6 Reserved */ uint8_t LPMUX:1; /*!< bit: 7 Low-Power Mux */ } bit; /*!< Structure used for bit access */ uint8_t reg; /*!< Type used for register access */ } AC_CTRLA_Type; #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ ```
ac.h:84-98 ```cpp /* -------- AC_CTRLB : (AC Offset: 0x01) ( /W 8) Control B -------- */ #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) typedef union { struct { uint8_t START0:1; /*!< bit: 0 Comparator 0 Start Comparison */ uint8_t START1:1; /*!< bit: 1 Comparator 1 Start Comparison */ uint8_t :6; /*!< bit: 2.. 7 Reserved */ } bit; /*!< Structure used for bit access */ struct { uint8_t START:2; /*!< bit: 0.. 1 Comparator x Start Comparison */ uint8_t :6; /*!< bit: 2.. 7 Reserved */ } vec; /*!< Structure used for vec access */ uint8_t reg; /*!< Type used for register access */ } AC_CTRLB_Type; #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ ```
ac.h:112-135 ```cpp /* -------- AC_EVCTRL : (AC Offset: 0x02) (R/W 16) Event Control -------- */ #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) typedef union { struct { uint16_t COMPEO0:1; /*!< bit: 0 Comparator 0 Event Output Enable */ uint16_t COMPEO1:1; /*!< bit: 1 Comparator 1 Event Output Enable */ uint16_t :2; /*!< bit: 2.. 3 Reserved */ uint16_t WINEO0:1; /*!< bit: 4 Window 0 Event Output Enable */ uint16_t :3; /*!< bit: 5.. 7 Reserved */ uint16_t COMPEI0:1; /*!< bit: 8 Comparator 0 Event Input */ uint16_t COMPEI1:1; /*!< bit: 9 Comparator 1 Event Input */ uint16_t :6; /*!< bit: 10..15 Reserved */ } bit; /*!< Structure used for bit access */ struct { uint16_t COMPEO:2; /*!< bit: 0.. 1 Comparator x Event Output Enable */ uint16_t :2; /*!< bit: 2.. 3 Reserved */ uint16_t WINEO:1; /*!< bit: 4 Window x Event Output Enable */ uint16_t :3; /*!< bit: 5.. 7 Reserved */ uint16_t COMPEI:2; /*!< bit: 8.. 9 Comparator x Event Input */ uint16_t :6; /*!< bit: 10..15 Reserved */ } vec; /*!< Structure used for vec access */ uint16_t reg; /*!< Type used for register access */ } AC_EVCTRL_Type; #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ ```

It seems to me like the basic types for SAMD are somehow missing. Or this could be a false positive?

But how could that be the case if clangd has succesfully extracted the system includes? ```shell V[07:24:53.297] System include extraction: target extracted: "arm-none-eabi" V[07:24:53.297] System include extraction: adding c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1 V[07:24:53.297] System include extraction: adding c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/arm-none-eabi V[07:24:53.297] System include extraction: adding c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/backward V[07:24:53.297] System include extraction: adding c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include V[07:24:53.297] System include extraction: adding c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include-fixed V[07:24:53.297] System include extraction: adding c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include I[07:24:53.297] System includes extractor: successfully executed C:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4/bin/arm-none-eabi-g++.exe got includes: "c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1, c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/arm-none-eabi, c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/backward, c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include, c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include-fixed, c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include" got target: "arm-none-eabi" I[07:24:53.315] ASTWorker building file c:\source\repos\clangd-arduino\clangd-arduino.ino version 1 with command inferred from c:\source\repos\clangd-arduino\build\sketch\clangd-arduino.ino.cpp [c:\Users\falve\.vscode\extensions\vsciot-vscode.vscode-arduino-0.4.3\out\src] C:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\arm-none-eabi-g++.exe --target=arm-none-eabi --driver-mode=g++ -mcpu=cortex-m0plus -mthumb -c -g -Os -w -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DF_CPU=48000000L -DARDUINO=10607 -DARDUINO_SAMD_MKRWIFI1010 -DARDUINO_ARCH_SAMD -DUSE_ARDUINO_MKR_PIN_LAYOUT -D__SAMD21G18A__ -DUSB_VID=0x2341 -DUSB_PID=0x8054 -DUSBCON -DUSB_MANUFACTURER="Arduino LLC" -DUSB_PRODUCT="Arduino MKR WiFi 1010" -DUSE_BQ24195L_PMIC -IC:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0/CMSIS/Include/ -IC:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/ -IC:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino/api/deprecated -IC:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino/api/deprecated-avr-comp -IC:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino -IC:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\variants\mkrwifi1010 -x c++-header -std=gnu++11 c:\source\repos\clangd-arduino\clangd-arduino.ino -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1 -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/arm-none-eabi -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/backward -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include-fixed -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include -fsyntax-only -resource-dir=c:\Users\falve\AppData\Roaming\Code\User\globalStorage\llvm-vs-code-extensions.vscode-clangd\install\12.0.0\clangd_12.0.0\lib\clang\12.0.0 V[07:24:53.328] Driver produced command: cc1 -cc1 -triple thumbv6m-none-unknown-eabi -fsyntax-only -disable-free -disable-llvm-verifier -discard-value-names -main-file-name clangd-arduino.ino -mrelocation-model static -mframe-pointer=all -fmath-errno -fno-rounding-math -fno-verbose-asm -mconstructor-aliases -nostdsysteminc -target-cpu cortex-m0plus -target-feature +soft-float-abi -target-feature -crc -target-feature -crypto -target-feature -sha2 -target-feature -aes -target-feature -dotprod -target-feature -dsp -target-feature -mve -target-feature -mve.fp -target-feature -fullfp16 -target-feature -ras -target-feature -bf16 -target-feature -sb -target-feature -i8mm -target-feature -lob -target-feature -cdecp0 -target-feature -cdecp1 -target-feature -cdecp2 -target-feature -cdecp3 -target-feature -cdecp4 -target-feature -cdecp5 -target-feature -cdecp6 -target-feature -cdecp7 -target-feature -hwdiv-arm -target-feature -hwdiv -target-feature -fp16fml -target-feature +strict-align -target-abi aapcs -mfloat-abi soft -fallow-half-arguments-and-returns -fno-split-dwarf-inlining -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -ffunction-sections -fdata-sections -resource-dir c:\Users\falve\AppData\Roaming\Code\User\globalStorage\llvm-vs-code-extensions.vscode-clangd\install\12.0.0\clangd_12.0.0\lib\clang\12.0.0 -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1 -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/arm-none-eabi -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/backward -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include-fixed -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include -D F_CPU=48000000L -D ARDUINO=10607 -D ARDUINO_SAMD_MKRWIFI1010 -D ARDUINO_ARCH_SAMD -D USE_ARDUINO_MKR_PIN_LAYOUT -D __SAMD21G18A__ -D USB_VID=0x2341 -D USB_PID=0x8054 -D USBCON -D USB_MANUFACTURER="Arduino LLC" -D USB_PRODUCT="Arduino MKR WiFi 1010" -D USE_BQ24195L_PMIC -I C:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0/CMSIS/Include/ -I C:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/ -I C:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino/api/deprecated -I C:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino/api/deprecated-avr-comp -I C:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino -I C:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\variants\mkrwifi1010 -internal-isystem C:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/clang-runtimes\arm-none-eabi\include\c++\v1 -internal-isystem c:\Users\falve\AppData\Roaming\Code\User\globalStorage\llvm-vs-code-extensions.vscode-clangd\install\12.0.0\clangd_12.0.0\lib\clang\12.0.0\include -internal-isystem C:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/clang-runtimes\arm-none-eabi\include -Os -w -std=gnu++11 -fdeprecated-macro -fdebug-compilation-dir c:\Users\falve\.vscode\extensions\vsciot-vscode.vscode-arduino-0.4.3\out\src -ferror-limit 19 -fno-rtti -fno-signed-char -fgnuc-version=4.2.1 -fno-threadsafe-statics -vectorize-loops -vectorize-slp -faddrsig -x c++-header c:\source\repos\clangd-arduino\clangd-arduino.ino ```
kadircet commented 3 years ago

This is probably about the definition of __I macro. You can check where it is defined to see if there's anything interesting.

Falven commented 3 years ago

This is probably about the definition of __I macro. You can check where it is defined to see if there's anything interesting.

It sounds like you may have a good idea of what is going on. I did notice that this ac.h file never includes stdint.h but that shouldn't be a problem, right? But are you expecting the compiler to be modified to work with clangd?

I found where __I is defined.

Here's the clangd output when opening core_cm0plus.h. ```shell V[11:30:10.861] System include extraction: target extracted: "arm-none-eabi" V[11:30:10.861] System include extraction: adding c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1 V[11:30:10.861] System include extraction: adding c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/arm-none-eabi V[11:30:10.861] System include extraction: adding c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/backward V[11:30:10.861] System include extraction: adding c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include V[11:30:10.861] System include extraction: adding c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include-fixed V[11:30:10.861] System include extraction: adding c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include I[11:30:10.861] System includes extractor: successfully executed C:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4/bin/arm-none-eabi-g++.exe got includes: "c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1, c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/arm-none-eabi, c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/backward, c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include, c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include-fixed, c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include" got target: "arm-none-eabi" I[11:30:10.862] ASTWorker building file c:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0\CMSIS\Include\core_cm0plus.h version 1 with command inferred from C:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\variants\mkrwifi1010\variant.cpp [c:\Users\falve\.vscode\extensions\vsciot-vscode.vscode-arduino-0.4.3\out\src] C:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\arm-none-eabi-g++.exe --target=arm-none-eabi --driver-mode=g++ -mcpu=cortex-m0plus -mthumb -c -g -Os -w -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DF_CPU=48000000L -DARDUINO=10607 -DARDUINO_SAMD_MKRWIFI1010 -DARDUINO_ARCH_SAMD -DUSE_ARDUINO_MKR_PIN_LAYOUT -D__SAMD21G18A__ -DUSB_VID=0x2341 -DUSB_PID=0x8054 -DUSBCON -DUSB_MANUFACTURER="Arduino LLC" -DUSB_PRODUCT="Arduino MKR WiFi 1010" -DUSE_BQ24195L_PMIC -IC:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0/CMSIS/Include/ -IC:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/ -IC:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino/api/deprecated -IC:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino/api/deprecated-avr-comp -IC:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino -IC:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\variants\mkrwifi1010 -x c++-header -std=gnu++11 c:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0\CMSIS\Include\core_cm0plus.h -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1 -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/arm-none-eabi -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/backward -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include-fixed -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include -fsyntax-only -resource-dir=c:\Users\falve\AppData\Roaming\Code\User\globalStorage\llvm-vs-code-extensions.vscode-clangd\install\12.0.0\clangd_12.0.0\lib\clang\12.0.0 V[11:30:10.863] System include extraction: target extracted: "arm-none-eabi" V[11:30:10.863] System include extraction: adding c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1 V[11:30:10.863] System include extraction: adding c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/arm-none-eabi V[11:30:10.863] System include extraction: adding c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/backward V[11:30:10.863] System include extraction: adding c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include V[11:30:10.863] System include extraction: adding c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include-fixed V[11:30:10.863] System include extraction: adding c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include I[11:30:10.863] System includes extractor: successfully executed C:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4/bin/arm-none-eabi-g++.exe got includes: "c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1, c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/arm-none-eabi, c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/backward, c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include, c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include-fixed, c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include" got target: "arm-none-eabi" I[11:30:10.863] ASTWorker building file c:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0\CMSIS\Device\ATMEL\samd21\include\component\ac.h version 1 with command inferred from C:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\variants\mkrwifi1010\variant.cpp [c:\Users\falve\.vscode\extensions\vsciot-vscode.vscode-arduino-0.4.3\out\src] C:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\arm-none-eabi-g++.exe --target=arm-none-eabi --driver-mode=g++ -mcpu=cortex-m0plus -mthumb -c -g -Os -w -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DF_CPU=48000000L -DARDUINO=10607 -DARDUINO_SAMD_MKRWIFI1010 -DARDUINO_ARCH_SAMD -DUSE_ARDUINO_MKR_PIN_LAYOUT -D__SAMD21G18A__ -DUSB_VID=0x2341 -DUSB_PID=0x8054 -DUSBCON -DUSB_MANUFACTURER="Arduino LLC" -DUSB_PRODUCT="Arduino MKR WiFi 1010" -DUSE_BQ24195L_PMIC -IC:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0/CMSIS/Include/ -IC:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/ -IC:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino/api/deprecated -IC:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino/api/deprecated-avr-comp -IC:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino -IC:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\variants\mkrwifi1010 -x c++-header -std=gnu++11 c:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0\CMSIS\Device\ATMEL\samd21\include\component\ac.h -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1 -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/arm-none-eabi -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/backward -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include-fixed -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include -fsyntax-only -resource-dir=c:\Users\falve\AppData\Roaming\Code\User\globalStorage\llvm-vs-code-extensions.vscode-clangd\install\12.0.0\clangd_12.0.0\lib\clang\12.0.0 V[11:30:10.864] Driver produced command: cc1 -cc1 -triple thumbv6m-none-unknown-eabi -fsyntax-only -disable-free -disable-llvm-verifier -discard-value-names -main-file-name core_cm0plus.h -mrelocation-model static -mframe-pointer=all -fmath-errno -fno-rounding-math -fno-verbose-asm -mconstructor-aliases -nostdsysteminc -target-cpu cortex-m0plus -target-feature +soft-float-abi -target-feature -crc -target-feature -crypto -target-feature -sha2 -target-feature -aes -target-feature -dotprod -target-feature -dsp -target-feature -mve -target-feature -mve.fp -target-feature -fullfp16 -target-feature -ras -target-feature -bf16 -target-feature -sb -target-feature -i8mm -target-feature -lob -target-feature -cdecp0 -target-feature -cdecp1 -target-feature -cdecp2 -target-feature -cdecp3 -target-feature -cdecp4 -target-feature -cdecp5 -target-feature -cdecp6 -target-feature -cdecp7 -target-feature -hwdiv-arm -target-feature -hwdiv -target-feature -fp16fml -target-feature +strict-align -target-abi aapcs -mfloat-abi soft -fallow-half-arguments-and-returns -fno-split-dwarf-inlining -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -ffunction-sections -fdata-sections -resource-dir c:\Users\falve\AppData\Roaming\Code\User\globalStorage\llvm-vs-code-extensions.vscode-clangd\install\12.0.0\clangd_12.0.0\lib\clang\12.0.0 -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1 -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/arm-none-eabi -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/backward -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include-fixed -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include -D F_CPU=48000000L -D ARDUINO=10607 -D ARDUINO_SAMD_MKRWIFI1010 -D ARDUINO_ARCH_SAMD -D USE_ARDUINO_MKR_PIN_LAYOUT -D __SAMD21G18A__ -D USB_VID=0x2341 -D USB_PID=0x8054 -D USBCON -D USB_MANUFACTURER="Arduino LLC" -D USB_PRODUCT="Arduino MKR WiFi 1010" -D USE_BQ24195L_PMIC -I C:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0/CMSIS/Include/ -I C:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/ -I C:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino/api/deprecated -I C:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino/api/deprecated-avr-comp -I C:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino -I C:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\variants\mkrwifi1010 -internal-isystem C:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/clang-runtimes\arm-none-eabi\include\c++\v1 -internal-isystem c:\Users\falve\AppData\Roaming\Code\User\globalStorage\llvm-vs-code-extensions.vscode-clangd\install\12.0.0\clangd_12.0.0\lib\clang\12.0.0\include -internal-isystem C:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/clang-runtimes\arm-none-eabi\include -Os -w -std=gnu++11 -fdeprecated-macro -fdebug-compilation-dir c:\Users\falve\.vscode\extensions\vsciot-vscode.vscode-arduino-0.4.3\out\src -ferror-limit 19 -fno-rtti -fno-signed-char -fgnuc-version=4.2.1 -fno-threadsafe-statics -vectorize-loops -vectorize-slp -faddrsig -x c++-header c:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0\CMSIS\Include\core_cm0plus.h ... V[11:30:11.013] Trying to fix unresolved name "uint8_t" in scopes: [] V[11:30:11.013] Dex query tree: (LIMIT 10000 (& T=t8t T=nt8 T=uin T=int S= ?=Restricted For Code Completion)) V[11:30:11.013] Failed to calculate include insertion for file:///C:/Users/falve/AppData/Local/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/sys/_stdint.h into c:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0\CMSIS\Device\ATMEL\samd21\include\component\ac.h: Header not on include path V[11:30:11.014] Trying to fix unresolved name "uint8_t" in scopes: [] V[11:30:11.014] Failed to calculate include insertion for file:///C:/Users/falve/AppData/Local/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/sys/_stdint.h into c:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0\CMSIS\Device\ATMEL\samd21\include\component\ac.h: Header not on include path V[11:30:11.014] Trying to fix unresolved name "uint8_t" in scopes: [] V[11:30:11.014] Failed to calculate include insertion for file:///C:/Users/falve/AppData/Local/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/sys/_stdint.h into c:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0\CMSIS\Device\ATMEL\samd21\include\component\ac.h: Header not on include path V[11:30:11.015] Trying to fix unresolved name "uint8_t" in scopes: [] V[11:30:11.015] Failed to calculate include insertion for file:///C:/Users/falve/AppData/Local/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/sys/_stdint.h into c:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0\CMSIS\Device\ATMEL\samd21\include\component\ac.h: Header not on include path V[11:30:11.015] Trying to fix unresolved name "uint8_t" in scopes: [] V[11:30:11.015] Failed to calculate include insertion for file:///C:/Users/falve/AppData/Local/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/sys/_stdint.h into c:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0\CMSIS\Device\ATMEL\samd21\include\component\ac.h: Header not on include path V[11:30:11.015] Trying to fix unresolved name "uint8_t" in scopes: [] V[11:30:11.015] Failed to calculate include insertion for file:///C:/Users/falve/AppData/Local/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/sys/_stdint.h into c:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0\CMSIS\Device\ATMEL\samd21\include\component\ac.h: Header not on include path V[11:30:11.016] Trying to fix unresolved name "uint8_t" in scopes: [] V[11:30:11.016] Failed to calculate include insertion for file:///C:/Users/falve/AppData/Local/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/sys/_stdint.h into c:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0\CMSIS\Device\ATMEL\samd21\include\component\ac.h: Header not on include path V[11:30:11.016] Trying to fix unresolved name "uint8_t" in scopes: [] V[11:30:11.016] Failed to calculate include insertion for file:///C:/Users/falve/AppData/Local/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/sys/_stdint.h into c:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0\CMSIS\Device\ATMEL\samd21\include\component\ac.h: Header not on include path V[11:30:11.016] Trying to fix unresolved name "uint8_t" in scopes: [] V[11:30:11.016] Failed to calculate include insertion for file:///C:/Users/falve/AppData/Local/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/sys/_stdint.h into c:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0\CMSIS\Device\ATMEL\samd21\include\component\ac.h: Header not on include path V[11:30:11.017] Trying to fix unresolved name "uint8_t" in scopes: [] V[11:30:11.017] Failed to calculate include insertion for file:///C:/Users/falve/AppData/Local/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/sys/_stdint.h into c:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0\CMSIS\Device\ATMEL\samd21\include\component\ac.h: Header not on include path V[11:30:11.017] Trying to fix unresolved name "uint8_t" in scopes: [] V[11:30:11.017] Failed to calculate include insertion for file:///C:/Users/falve/AppData/Local/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/sys/_stdint.h into c:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0\CMSIS\Device\ATMEL\samd21\include\component\ac.h: Header not on include path V[11:30:11.017] Trying to fix unresolved name "uint8_t" in scopes: [] V[11:30:11.018] Failed to calculate include insertion for file:///C:/Users/falve/AppData/Local/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/sys/_stdint.h into c:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0\CMSIS\Device\ATMEL\samd21\include\component\ac.h: Header not on include path V[11:30:11.018] Trying to fix unresolved name "uint16_t" in scopes: [] V[11:30:11.018] Dex query tree: (LIMIT 10000 (& T=nt1 T=16t T=t16 T=uin T=int S= ?=Restricted For Code Completion)) V[11:30:11.018] Failed to calculate include insertion for file:///C:/Users/falve/AppData/Local/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/sys/_stdint.h into c:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0\CMSIS\Device\ATMEL\samd21\include\component\ac.h: Header not on include path V[11:30:11.019] Trying to fix unresolved name "uint16_t" in scopes: [] V[11:30:11.019] Failed to calculate include insertion for file:///C:/Users/falve/AppData/Local/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/sys/_stdint.h into c:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0\CMSIS\Device\ATMEL\samd21\include\component\ac.h: Header not on include path V[11:30:11.019] Trying to fix unresolved name "uint16_t" in scopes: [] V[11:30:11.019] Failed to calculate include insertion for file:///C:/Users/falve/AppData/Local/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/sys/_stdint.h into c:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0\CMSIS\Device\ATMEL\samd21\include\component\ac.h: Header not on include path V[11:30:11.020] Trying to fix unresolved name "uint16_t" in scopes: [] V[11:30:11.020] Failed to calculate include insertion for file:///C:/Users/falve/AppData/Local/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/sys/_stdint.h into c:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0\CMSIS\Device\ATMEL\samd21\include\component\ac.h: Header not on include path V[11:30:11.020] Trying to fix unresolved name "uint16_t" in scopes: [] V[11:30:11.021] Failed to calculate include insertion for file:///C:/Users/falve/AppData/Local/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/sys/_stdint.h into c:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0\CMSIS\Device\ATMEL\samd21\include\component\ac.h: Header not on include path V[11:30:11.021] Trying to fix unresolved name "uint16_t" in scopes: [] V[11:30:11.021] Failed to calculate include insertion for file:///C:/Users/falve/AppData/Local/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/sys/_stdint.h into c:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0\CMSIS\Device\ATMEL\samd21\include\component\ac.h: Header not on include path V[11:30:11.023] Trying to fix unresolved name "uint16_t" in scopes: [] V[11:30:11.023] Failed to calculate include insertion for file:///C:/Users/falve/AppData/Local/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/sys/_stdint.h into c:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0\CMSIS\Device\ATMEL\samd21\include\component\ac.h: Header not on include path ... V[11:30:11.064] Trying to fix unresolved name "IRQn_Type" in scopes: [] V[11:30:11.064] Dex query tree: false V[11:30:11.065] Trying to fix unresolved name "IRQn_Type" in scopes: [] V[11:30:11.065] Trying to fix unresolved name "IRQn_Type" in scopes: [] V[11:30:11.066] Trying to fix unresolved name "IRQn_Type" in scopes: [] V[11:30:11.066] Trying to fix unresolved name "IRQn_Type" in scopes: [] V[11:30:11.066] Trying to fix unresolved name "IRQn_Type" in scopes: [] V[11:30:11.068] Trying to fix unresolved name "__NVIC_PRIO_BITS" in scopes: [] ```
And here are some of the errors in the core_cm0plus.h ```cpp // Unknown type name 'IRQn_Type'; did you mean 'IPSR_Type'? __STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn) { // Cannot convert 'IPSR_Type' to 'int32_t' return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); } // Cannot convert 'IPSR_Type' to 'int32_t' if ((int32_t)(IRQn) < 0) { // Use of undeclared identifier '__NVIC_PRIO_BITS' SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); } ```
But I think the clangd output above has a better hint! ``` Failed to calculate include insertion for file:///C:/Users/falve/AppData/Local/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/sys/_stdint.h into c:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0\CMSIS\Device\ATMEL\samd21\include\component\ac.h: Header not on include path ```

I may have found the bug. It can't include _stdint.h... even though it is in the include path. Does this have something to do with --sysroot?

I tried adding the following in my .clangd ```shell CompileFlags: Add: [ "--sysroot=C:\\Users\\falve\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\7-2017q4", ] ```
Corresponding clangd output when opening core_cm0plus.h ```shell V[16:05:12.425] config note at c:\source\repos\clangd-arduino\.clangd:1:0: Parsing config fragment V[16:05:12.425] config note at c:\source\repos\clangd-arduino\.clangd:1:0: Parsed 1 fragments from file V[16:05:12.426] Config fragment: compiling c:\source\repos\clangd-arduino\.clangd:1 -> 0x000001657F7D6280 (trusted=false) I[16:05:12.426] --> textDocument/publishDiagnostics V[16:05:12.426] >>> {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[],"uri":"file:///c:/source/repos/clangd-arduino/.clangd"}} V[16:05:12.501] System include extraction: target extracted: "arm-none-eabi" V[16:05:12.501] System include extraction: adding c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1 V[16:05:12.501] System include extraction: adding c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/arm-none-eabi V[16:05:12.501] System include extraction: adding c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/backward V[16:05:12.501] System include extraction: adding c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include V[16:05:12.501] System include extraction: adding c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include-fixed V[16:05:12.501] System include extraction: adding c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include I[16:05:12.501] System includes extractor: successfully executed C:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4/bin/arm-none-eabi-g++.exe got includes: "c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1, c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/arm-none-eabi, c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/backward, c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include, c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include-fixed, c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include" got target: "arm-none-eabi" I[16:05:12.502] ASTWorker building file c:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0\CMSIS\Include\core_cm0plus.h version 1 with command inferred from C:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\variants\mkrwifi1010\variant.cpp [c:\Users\falve\.vscode\extensions\vsciot-vscode.vscode-arduino-0.4.3\out\src] C:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\arm-none-eabi-g++.exe --target=arm-none-eabi --driver-mode=g++ -mcpu=cortex-m0plus -mthumb -c -g -Os -w -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DF_CPU=48000000L -DARDUINO=10607 -DARDUINO_SAMD_MKRWIFI1010 -DARDUINO_ARCH_SAMD -DUSE_ARDUINO_MKR_PIN_LAYOUT -D__SAMD21G18A__ -DUSB_VID=0x2341 -DUSB_PID=0x8054 -DUSBCON -DUSB_MANUFACTURER="Arduino LLC" -DUSB_PRODUCT="Arduino MKR WiFi 1010" -DUSE_BQ24195L_PMIC -IC:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0/CMSIS/Include/ -IC:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/ -IC:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino/api/deprecated -IC:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino/api/deprecated-avr-comp -IC:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino -IC:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\variants\mkrwifi1010 -x c++-header -std=gnu++11 c:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0\CMSIS\Include\core_cm0plus.h -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1 -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/arm-none-eabi -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/backward -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include-fixed -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include -fsyntax-only -resource-dir=c:\Users\falve\AppData\Roaming\Code\User\globalStorage\llvm-vs-code-extensions.vscode-clangd\install\12.0.0\clangd_12.0.0\lib\clang\12.0.0 V[16:05:12.504] Driver produced command: cc1 -cc1 -triple thumbv6m-none-unknown-eabi -fsyntax-only -disable-free -disable-llvm-verifier -discard-value-names -main-file-name core_cm0plus.h -mrelocation-model static -mframe-pointer=all -fmath-errno -fno-rounding-math -fno-verbose-asm -mconstructor-aliases -nostdsysteminc -target-cpu cortex-m0plus -target-feature +soft-float-abi -target-feature -crc -target-feature -crypto -target-feature -sha2 -target-feature -aes -target-feature -dotprod -target-feature -dsp -target-feature -mve -target-feature -mve.fp -target-feature -fullfp16 -target-feature -ras -target-feature -bf16 -target-feature -sb -target-feature -i8mm -target-feature -lob -target-feature -cdecp0 -target-feature -cdecp1 -target-feature -cdecp2 -target-feature -cdecp3 -target-feature -cdecp4 -target-feature -cdecp5 -target-feature -cdecp6 -target-feature -cdecp7 -target-feature -hwdiv-arm -target-feature -hwdiv -target-feature -fp16fml -target-feature +strict-align -target-abi aapcs -mfloat-abi soft -fallow-half-arguments-and-returns -fno-split-dwarf-inlining -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -ffunction-sections -fdata-sections -resource-dir c:\Users\falve\AppData\Roaming\Code\User\globalStorage\llvm-vs-code-extensions.vscode-clangd\install\12.0.0\clangd_12.0.0\lib\clang\12.0.0 -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1 -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/arm-none-eabi -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/backward -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/include-fixed -isystem c:\users\falve\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include -D F_CPU=48000000L -D ARDUINO=10607 -D ARDUINO_SAMD_MKRWIFI1010 -D ARDUINO_ARCH_SAMD -D USE_ARDUINO_MKR_PIN_LAYOUT -D __SAMD21G18A__ -D USB_VID=0x2341 -D USB_PID=0x8054 -D USBCON -D USB_MANUFACTURER="Arduino LLC" -D USB_PRODUCT="Arduino MKR WiFi 1010" -D USE_BQ24195L_PMIC -I C:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0/CMSIS/Include/ -I C:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/ -I C:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino/api/deprecated -I C:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino/api/deprecated-avr-comp -I C:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\cores\arduino -I C:\Users\falve\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\variants\mkrwifi1010 -internal-isystem C:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/clang-runtimes\arm-none-eabi\include\c++\v1 -internal-isystem c:\Users\falve\AppData\Roaming\Code\User\globalStorage\llvm-vs-code-extensions.vscode-clangd\install\12.0.0\clangd_12.0.0\lib\clang\12.0.0\include -internal-isystem C:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\../lib/clang-runtimes\arm-none-eabi\include -Os -w -std=gnu++11 -fdeprecated-macro -fdebug-compilation-dir c:\Users\falve\.vscode\extensions\vsciot-vscode.vscode-arduino-0.4.3\out\src -ferror-limit 19 -fno-rtti -fno-signed-char -fgnuc-version=4.2.1 -fno-threadsafe-statics -vectorize-loops -vectorize-slp -faddrsig -x c++-header c:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0\CMSIS\Include\core_cm0plus.h I[16:05:12.504] --> textDocument/clangd.fileStatus V[16:05:12.504] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"parsing includes, running Update (1)","uri":"file:///c:/Users/falve/AppData/Local/Arduino15/packages/arduino/tools/CMSIS/4.5.0/CMSIS/Include/core_cm0plus.h"}} V[16:05:12.504] Building first preamble for c:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0\CMSIS\Include\core_cm0plus.h version 1 V[16:05:12.520] BackgroundIndex: building version 1 after loading index from disk V[16:05:12.543] indexed preamble AST for c:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0\CMSIS\Include\core_cm0plus.h version 1: symbol slab: 201 symbols, 50856 bytes ref slab: 0 symbols, 0 refs, 136 bytes relations slab: 0 relations, 24 bytes V[16:05:12.545] Build dynamic index for header symbols with estimated memory usage of 255996 bytes V[16:05:12.582] Built preamble of size 375412 for file c:\Users\falve\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0\CMSIS\Include\core_cm0plus.h version 1 V[16:05:12.683] Trying to fix unresolved name "IRQn_Type" in scopes: [] V[16:05:12.683] Dex query tree: false V[16:05:12.686] Trying to fix unresolved name "IRQn_Type" in scopes: [] V[16:05:12.687] Trying to fix unresolved name "IRQn_Type" in scopes: [] V[16:05:12.687] Trying to fix unresolved name "IRQn_Type" in scopes: [] V[16:05:12.688] Trying to fix unresolved name "IRQn_Type" in scopes: [] ```

but it didn't change anything.

I think it may have something to do with stdint. ```cpp #ifndef _GCC_WRAP_STDINT_H #if __STDC_HOSTED__ # if defined __cplusplus && __cplusplus >= 201103L # undef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS # undef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS # endif // Main file cannot be included recursively when building a preamble # include_next #else # include "stdint-gcc.h" #endif #define _GCC_WRAP_STDINT_H #endif ```

This seems to potentially be the first error that causes all others.

kadircet commented 3 years ago

Sorry feels like this is getting messier and away from land of clangd. First of all, clangd would provide really poor results on those internal headers without a proper project setup for those. It is fine to include them in another project as they can usually be compiled as part of your project with good compile flags clangd has access to, but if you open them directly story changes a lot since the flags are usually from far away directories and even more those headers are not necessarily self-contained (e.g. they are only meaningful as part of a bigger translation unit that includes a bunch of other code before that particular header).

I was suggesting the location of __I but don't see anything around that in your last message. It is probably the case that __I is defined with a cv-qualifier in some configs and without in others (by depending on some macros). I was suggesting you figure out which branch clangd should use and find out why it is not using that one.

Falven commented 3 years ago

Sorry feels like this is getting messier and away from land of clangd. First of all, clangd would provide really poor results on those internal headers without a proper project setup for those. It is fine to include them in another project as they can usually be compiled as part of your project with good compile flags clangd has access to, but if you open them directly story changes a lot since the flags are usually from far away directories and even more those headers are not necessarily self-contained (e.g. they are only meaningful as part of a bigger translation unit that includes a bunch of other code before that particular header).

Right, I don't specifically care about errors from clangd when I open non-project files, but unfortunately these errors spill over to any of my code and cause all sorts of false positives on basic stuff like initializing strings. It is pretty much unusable. Again I don't understand if the project files compile fine with G++ why should it be any different with clangd intellisense? Why does clangd show any errors? Does clangd aggressively try to compile files that are not part of the project or included, even when I don't open them? It makes no sense.

I was suggesting the location of __I but don't see anything around that in your last message. It is probably the case that __I is defined with a cv-qualifier in some configs and without in others (by depending on some macros). I was suggesting you figure out which branch clangd should use and find out why it is not using that one.

I'll keep looking, I guess...

HighCommander4 commented 3 years ago

Does clangd aggressively try to compile files that are not part of the project or included, even when I don't open them?

I'm sure you're aware that C and C++ compilers operate at the level of "translation units". That is to say, while a compilation command may only be given one input file, any #include-ed files need to be read as well, and the declarations inside them processed by the compiler. Clangd is no different: it needs to process the declarations in headers to be able to correctly process the declarations in the main file.

but unfortunately these errors spill over to any of my code and cause all sorts of false positives on basic stuff like initializing strings.

That's just it: even if you suppress the errors coming from the headers, not being able to correctly parse the declarations in the headers will mean not being able to correctly handle code in the main file which uses those declarations.