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

相关推荐
刘延林.2 小时前
Visual Studio Code+PlatformIO + ESP32-S3 + Arduino 框架点亮一个小的led灯-测试
ide·vscode·编辑器
Dontla4 小时前
VSCode插件Git Graph介绍(Git可视化管理分支、可视化Git)
ide·git·vscode
2501_916007474 小时前
从零开始学习iOS开发:Xcode环境配置与项目创建完整指南
ide·vscode·学习·ios·个人开发·xcode·敏捷流程
π同学5 小时前
ESP-IDF+vscode开发ESP32第六讲——SPI
vscode·esp32·spi
SiYuanFeng5 小时前
打开vscode总是提示未找到python的解决办法(打开终端却能找到)
ide·vscode·python
Webgiserin1 天前
nvm+vscode配置安装暂记
ide·vscode·编辑器
charlie1145141911 天前
嵌入式C++工程实践——第13篇:第一次重构 —— enum class取代宏,类型安全的开始
开发语言·c++·vscode·stm32·安全·重构·现代c++
传说中胖子1 天前
Magento服务器VSCode开启XDebug方法
服务器·vscode·php
davidson14711 天前
VSCode配置Claude Code
vscode·ai·大模型·claude
AI 赋能1 天前
Claude Code for VS Code 使用手册
vscode·claude