增加Vscode引用路径

增加Vscode引用路径

增加Vscode引用路径

问题说明

在嵌入式开发中需要经常用到库函数(SPL), Vscode需要配置引用路径才能对函数名或变量进行跳转

解决思路1

与Keil5 MDK类似, 在配置C/C++的json文件中添加所使用的头文件路径

在Vscode中进行配置

在vscode中按Ctrl+Shift+P 输入configuration, 如图选择C/C++编程配置(json)

在"includePath"后面增加所要使用的头文件的路径, 如下图所示

缺点

配置起来较为繁琐, 且部分函数依然无法跳转

解决思路2

在思路1的基础上, 向编写的文件中包含"stm32f10x_conf.h文件"

c 复制代码
#include "stm32f10x_conf.h"

在stm32f10x_conf文件中有对于所有外设头文件的包含

c 复制代码
/* Includes ------------------------------------------------------------------*/
/* Uncomment/Comment the line below to enable/disable peripheral header file inclusion */
#include "stm32f10x_adc.h"
#include "stm32f10x_bkp.h"
#include "stm32f10x_can.h"
#include "stm32f10x_cec.h"
#include "stm32f10x_crc.h"
#include "stm32f10x_dac.h"
#include "stm32f10x_dbgmcu.h"
#include "stm32f10x_dma.h"
#include "stm32f10x_exti.h"
#include "stm32f10x_flash.h"
#include "stm32f10x_fsmc.h"
#include "stm32f10x_gpio.h"
#include "stm32f10x_i2c.h"
#include "stm32f10x_iwdg.h"
#include "stm32f10x_pwr.h"
#include "stm32f10x_rcc.h"
#include "stm32f10x_rtc.h"
#include "stm32f10x_sdio.h"
#include "stm32f10x_spi.h"
#include "stm32f10x_tim.h"
#include "stm32f10x_usart.h"
#include "stm32f10x_wwdg.h"
#include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */

所以在思路1的基础上加上思路2可以较好的解决该问题

相关推荐
螺丝钉code8 小时前
迁移到 Openrouter 后 Claude Code Vscode 插件出现了一些奇怪的问题
ide·vscode·编辑器
Dontla21 小时前
VScode插件SQLite Viewer介绍(允许开发者不离开编辑器,直接打开、浏览和查询SQLite数据库文件)(ChromaDB、向量库插件、数据库插件、.sqlite3)DBeaver
数据库·vscode
Robot_Nav1 天前
VSCode 调试 ROS1/ROS2 等项目完整指南
vscode·机器人·ros
pacong1 天前
vscode使用
javascript·vue.js·vscode
qq_283720051 天前
VSCode 编译 Qt 5.12 QML 完整教程(Windows + MinGW)
windows·vscode·qt
π同学1 天前
ESP-IDF+vscode开发ESP32第三讲——UART
vscode·esp32·uart·esp-idf
旺旺的碎冰冰~1 天前
解决VScode使用GitHub Copilot生成的命令行无法显示问题
vscode·github·copilot
肖恭伟1 天前
Cursor(VSCode) + clangd 无法跳转 Qt 类/变量
ide·vscode·qt
ChindongX1 天前
Visual Studio Code 搭建 SVN环境
ide·vscode·svn
RanMaxLi1 天前
【ssh】vscode使用ssh链接服务器失败
服务器·vscode·ssh