0

On Windows 11 with vscode and the ESP-IDF plugin compiling with riscv32-esp-elf/esp-2022r1-11.2.0/riscv32-esp-elf/bin/riscv32-esp-elf-gcc.exe, if settings.json has

    "C_Cpp.codeAnalysis.clangTidy.enabled": true,

then the standard libraries fail to lint, because in stddef.h:

#if !(defined (__GNUG__) && defined (size_t))
typedef __SIZE_TYPE__ size_t;
typedef redefinition with different types ('unsigned int' vs 'unsigned long long')

stddef.h in this case is the one from esp-idf-tools\tools\riscv32-esp-elf\esp-2022r1-11.2.0\riscv32-esp-elf\lib\gcc\riscv32-esp-elf\11.2.0\include\stddef.h.

Apparently __GNU_G__ is specific to g++ which I am not using.

Among other things, I've tried setting this in c_cpp_properties.json:

{
    "configurations": [
        {
            "name": "riscv32",
            "includePath": [
                "${workspaceFolder}/**",
                "/ProgramData/esp-idf/components/**",
                "/ProgramData/esp-rainmaker/components/**",
                "/ProgramData/esp-rainmaker/components/esp_rainmaker/include/**"
            ],
            "defines": [
                "_GNU_SOURCE=1",
                "_POSIX_READER_WRITER_LOCKS=1",
                "ESP_PLATFORM=1",
                "configENABLE_FREERTOS_DEBUG_OCDAWARE=1",
                "IDF_VER=v5.0.1"
            ],
            "compilerPath": "/ProgramData/esp-idf-tools/tools/riscv32-esp-elf/esp-2022r1-11.2.0/riscv32-esp-elf/bin/riscv32-esp-elf-gcc.exe",
            "cStandard": "gnu17",
            "intelliSenseMode": "windows-gcc-arm",
            "compileCommands": "${workspaceFolder}/build/compile_commands.json",
            "configurationProvider": "ms-vscode.cmake-tools"
        }
    ],
    "version": 4
}

I've also tried an extended version of defines pulled from the output of

echo | \
/c/ProgramData/esp-idf-tools/tools/riscv32-esp-elf/esp-2022r1-11.2.0/riscv32-esp-elf/bin/riscv32-esp-elf-gcc.exe \
-march=rv32imc \
-Og \
-DconfigENABLE_FREERTOS_DEBUG_OCDAWARE=1 \
-std=gnu17 \
-Wno-old-style-declaration \
-D_GNU_SOURCE \
-DIDF_VER="v5.0.1" \
-DESP_PLATFORM \
-D_POSIX_READER_WRITER_LOCKS \
-dM -E -

which generates 319 defines but does not solve the issue.

Reinderien
  • 11,755
  • 5
  • 49
  • 77

0 Answers0