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

相关推荐
HealthScience4 小时前
codex、WSL中使用(cursor)使用chrome-devtools-mcp最佳实践
vscode
pu_taoc16 小时前
深入剖析:基于epoll与主从Reactor模型的高性能服务器设计与实现
服务器·c语言·c++·vscode
YoungHong19921 天前
一行配置解决claude code 2.0版本更新后 vscode 插件需要登录的问题
ide·vscode·编辑器
Blue桃之夭夭1 天前
git和VScode
ide·git·vscode
蜀中廖化2 天前
python VSCode中报错 E501:line too long (81 > 79 characters)
开发语言·vscode·python
shimly1234562 天前
vscode 指定连接其它版本的 linux
ide·vscode·编辑器
___波子 Pro Max.2 天前
VS Code文件监视排除设置详解
vscode
larry_dongy2 天前
【学习记录】vscode+ros2+cpp调试
vscode·学习
vortex52 天前
vscode-background 扩展的原理、配置和使用
ide·vscode·编辑器
饭来_2 天前
通过 SSH 远程连接 docker 容器
vscode·docker·ssh