如何在VSCode中为RP2040(Pico)配置IntelliSense
VSCode中RP2040(Pico)的IntelliSense配置问题
我查过类似问题,但没找到有效解决方案,可能是漏了关键步骤。
现在我在VSCode里给RP2040(Pico)配置IntelliSense,已经能用CMake成功构建项目,还把程序传到MCU上跑起来了,但IntelliSense没法像处理普通C/C++文件那样正常工作——哪怕直接指定pico-sdk目录的精确路径(比如.h和.c文件的位置),它还是找不到、识别不了SDK里的库。
我的项目里的c_cpp_properties.json内容如下:
{ "configurations": [ { "name": "RP2040", "includePath": [ "${workspaceFolder}/**", "C:/Users/Julio/VSARM/sdk/pico/pico-sdk/src/**", "${env:PICO_SDK_PATH}/**", "${workspaceFolder}/build/pico-sdk/**" ], "defines": [ "_DEBUG", "UNICODE", "_UNICODE" ], "windowsSdkVersion": "10.0.22000.0", "compilerPath": "C:/Users/Julio/VSARM/armcc/10 2021.10/bin/arm-none-eabi-gcc.exe", "intelliSenseMode": "gcc-arm", "cStandard": "c11", "cppStandard": "c++17", "configurationProvider": "ms-vscode.makefile-tools" } ], "version": 4 }
我试过好几个我觉得是库所在位置的路径,但都没用。其中"${workspaceFolder}/build/pico-sdk/**"是因为CMake构建时会在build文件夹里生成pico-sdk目录,原以为这样配置能生效,但还是不行。
附上我的CMakeLists.txt供参考:
cmake_minimum_required(VERSION 3.12) # Pull in SDK (must be before project) include(pico_sdk_import.cmake) project(blink C CXX ASM) set(CMAKE_C_STANDARD 11) set(CMAKE_CXX_STANDARD 17) # Initialize the SDK and include the libraries pico_sdk_init() # Tell CMake where to find the executable source file add_executable(${PROJECT_NAME} main.c ) # Create map/bin/hex/uf2 files pico_add_extra_outputs(${PROJECT_NAME}) # Link to pico_stdlib (gpio, time, etc. functions) target_link_libraries(${PROJECT_NAME} pico_stdlib ) # Enable usb output, disable uart output pico_enable_stdio_usb(${PROJECT_NAME} 1) pico_enable_stdio_uart(${PROJECT_NAME} 0) add_compile_options(-Wall -Wno-format # int != int32_t as far as the compiler is concerned because gcc has int32_t as long int -Wno-unused-function # we have some for the docs that aren't called -Wno-maybe-uninitialized )
有没有办法让VSCode的IntelliSense和CMake配合工作?这样应该能解决问题吧?我确认项目构建没问题,所以应该是VSCode这边的配置问题。
更新:在尝试用CMake做IntelliSense提供程序之前,我偶然让IntelliSense识别到了Pico的库——当时我同时打开了一个无关的C++项目,某个扩展自动配置后就好了,但我不知道具体原因。这显然不是规范的解决方法,所以还是想尝试通过CMake来正确配置。
内容的提问来源于stack exchange,提问作者Some random guy
相关产品推荐
相关产品推荐

