VSCode + ESP-IDF 问题 identifier XXX is undefined

发布时间 2023-10-09 16:35:18作者: Champrin

VSCode + ESP-IDF 问题 identifier XXX is undefined

VSCode会出现错误提示如:

identifier "CONFIG_IDF_TARGET" is undefinedC/C++(20)

identifier "CONFIG_FREERTOS_HZ" is undefinedC/C++(20)

解决办法:
C++ Configurations 加入 "compileCommands": "${workspaceFolder}/build/

{
    "configurations": [
        {
            "name": "ESP-IDF",
            "compileCommands": "${workspaceFolder}/build/compile_commands.json",
            "compilerPath": "d:\\espressif\\tools\\xtensa-esp32s3-elf\\esp-12.2.0_20230208\\xtensa-esp32s3-elf\\bin\\xtensa-esp32s3-elf-gcc.exe",
            "includePath": [
                "${config:idf.espIdfPath}/components/**",
                "${config:idf.espIdfPathWin}/components/**",
                "${config:idf.espAdfPath}/components/**",
                "${config:idf.espAdfPathWin}/components/**",
                "${workspaceFolder}/**"
            ],
            "browse": {
                "path": [
                    "${config:idf.espIdfPath}/components",
                    "${config:idf.espIdfPathWin}/components",
                    "${config:idf.espAdfPath}/components/**",
                    "${config:idf.espAdfPathWin}/components/**",
                    "${workspaceFolder}"
                ],
                "limitSymbolsToIncludedHeaders": false
            }
        }
    ],
    "version": 4
}

参考identifier "CONFIG_IDF_TARGET" is undefined和identifier "CONFIG_FREERTOS_HZ" is undefined (VSC-1138) #1008