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

相关推荐
我在看世界1 小时前
家里vscode连公司内网vscede
vscode·ssh
悠悠小茉莉4 小时前
Win11 安装 Visual Studio(保姆教程 - 更新至2025.07)
c++·ide·vscode·python·visualstudio·visual studio
SZ1701102315 小时前
华为云 银河麒麟 vscode远程连接
ide·vscode·华为云
yanjiee6 小时前
需要scl来指定编译器的clangd+cmake在vscode/cursor开发环境下的配置
ide·vscode·编辑器
Waltt_Qiope9 小时前
关于使用cursor tunnel链接vscode(避免1006 issue的做法)
ide·vscode·issue
Charlene Fung10 小时前
vs code远程自动登录服务器,无需手动输入密码的终极方案(windows版)
运维·服务器·vscode·ssh
奇文怪式12 小时前
VSCode+arm-none-eabi-gcc交叉编译+CMake构建+OpenOCD(基于Raspberry Pico RP2040)
arm开发·ide·vscode·rp2040
hero_heart20 小时前
vscode中c_cpp_properities.cpp文件生成和作用
ide·vscode·编辑器
DO ITNOW1 天前
Cursor/VScode ,点击运行按钮,就打开新的终端,如何设置为在当前终端运行文件而不是重新打开终端----一招搞定篇
ide·vscode·编辑器
小妖6661 天前
若 VSCode 添加到文件夹内右键菜单中显示
ide·vscode·编辑器