You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu下VS Code中nRF52+SDK15.2 IntelliSense跳转异常求助

解决方案

1. 添加ARM GCC标准库路径到c_cpp_properties.json

VS Code的C/C++插件默认优先搜索系统Clang的头文件,你需要手动将ARM GCC自带的标准库路径加入includePath,并放在靠前位置确保优先匹配。

对于gcc-arm-none-eabi-9-2020-q2-update工具链,标准头文件路径通常为:

  • ${compilerPath}/../arm-none-eabi/include
  • ${compilerPath}/../lib/gcc/arm-none-eabi/9.3.1/include
  • ${compilerPath}/../lib/gcc/arm-none-eabi/9.3.1/include-fixed

修改后的c_cpp_properties.json配置如下:

{
"env": {
    "nrfSDK": "/home/eyal/develop/sdks/nRF5_SDK_15.2.0_9412b96/"
},
"configurations": [
    {
        "name": "nrf52",
        "includePath": [
            "${compilerPath}/../arm-none-eabi/include",
            "${compilerPath}/../lib/gcc/arm-none-eabi/9.3.1/include",
            "${compilerPath}/../lib/gcc/arm-none-eabi/9.3.1/include-fixed",
            "${workspaceFolder}/**",
            "${nrfSDK}/components",
            "${nrfSDK}/components/softdevice/common",
            "${nrfSDK}/components/softdevice/s140/headers",
            "${nrfSDK}/components/softdevice/s140/headers/nrf52",
            "${nrfSDK}/components/toolchain/cmsis/include",
            "${nrfSDK}/components/libraries/**",
            "${nrfSDK}/components/boards",
            "${nrfSDK}/modules/**",
            "${nrfSDK}/modules/",
            "${nrfSDK}/integration/nrfx",
            "${nrfSDK}/integration/nrfx/legacy",
            "${nrfSDK}/external/**"
        ],
        "defines": [
            "BOARD_PCA10056",
            "BSP_DEFINES_ONLY",
            "CONFIG_GPIO_AS_PINRESET",
            "FLOAT_ABI_HARD",
            "NRF52840_XXAA"
        ],
        "compilerPath": "/home/eyal/develop/sdks/gcc-arm-none-eabi-9-2020-q2-update/bin/arm-none-eabi-gcc",
        "cStandard": "c11",
        "cppStandard": "c++14",
        "intelliSenseMode": "linux-gcc-arm",
        "compilerArgs": [
            "-O3",
            "-g3",
            "-mcpu=cortex-m4",
            "-mthumb",
            "-mabi=aapcs",
            "-Wall",
            "-Werror",
            "-mfloat-abi=hard",
            "-mfpu=fpv4-sp-d16",
            "-ffunction-sections",
            "-fdata-sections",
            "-fno-strict-aliasing",
            "-fno-builtin",
            "-fshort-enums"
        ]
    }
],
"version": 4
}

注意:将compilerArgs中的"-Wall -Werror"拆分为"-Wall"和"-Werror"两个独立参数,避免编译时参数解析错误。

2. 覆盖默认系统包含路径(可选)

若添加路径后问题仍存在,在settings.json中添加以下配置,强制插件使用ARM GCC的系统头文件:

{
    "C_Cpp.default.systemIncludePath": [
        "/home/eyal/develop/sdks/gcc-arm-none-eabi-9-2020-q2-update/arm-none-eabi/include",
        "/home/eyal/develop/sdks/gcc-arm-none-eabi-9-2020-q2-update/lib/gcc/arm-none-eabi/9.3.1/include",
        "/home/eyal/develop/sdks/gcc-arm-none-eabi-9-2020-q2-update/lib/gcc/arm-none-eabi/9.3.1/include-fixed"
    ]
}

3. 重启VS Code生效

按下Ctrl+Shift+P,输入Reload Window重启VS Code,测试头文件跳转功能是否恢复正常。


内容的提问来源于stack exchange,提问作者codeScriber

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.14 00:45:21