在 Windows 11 上使用 vscode 和 ESP-IDF 插件编译
riscv32-esp-elf/esp-2022r1-11.2.0/riscv32-esp-elf/bin/riscv32-esp-elf-gcc.exe
,如果settings.json
有
"C_Cpp.codeAnalysis.clangTidy.enabled": true,
然后标准库无法进行 lint,因为在
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
在这种情况下是来自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
.
显然
__GNU_G__
特定于我没有使用的g ++。
除其他外,我尝试在
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
}
我还尝试了从
的输出中提取的
defines
的扩展版本
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 -
生成 319 定义但没有解决问题。