增加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可以较好的解决该问题

相关推荐
鸡啄米的时光机7 小时前
vscode的一些实用操作
vscode·学习
灰色人生qwer11 小时前
React + TypeScript+ Vite 配置路径别名和vscode智能路径提示
vscode·react.js·typescript
莲动渔舟11 小时前
赶AI大潮:在VSCode中使用DeepSeek及近百种模型的极简方法
ide·人工智能·vscode·deepseek
咩咩大主教13 小时前
VSCode运行Go程序报错:Unable to process `evaluate`: debuggee is running
开发语言·ide·vscode·golang·编辑器
佛曰我不想说话13 小时前
通过VSCode直接连接使用 GPT的编程助手
ide·vscode·copilot
羊村懒哥16 小时前
VScode内接入deepseek包过程(本地部署版包会)
人工智能·vscode·deepseek
温酒往事·16 小时前
无缝对接[系列2]:在VSCode中继续接入本地DeepSeek的完整指南
ide·vscode·编辑器
Tom·猫1 天前
VSCODE - 连接远程linux服务器,报错XHR failed 解决方法
linux·服务器·vscode
艾斯比的日常1 天前
更高效实用 vscode 的常用设置
ide·vscode·编辑器
大得3691 天前
Visual Studio Code使用ai大模型编成
ide·vscode·编辑器