使用VScode配置STM32环境报错问题解决办法

使用VScode配置STM32环境报错问题解决办法

现象:部分.h文件出现uint8_t 未定义报错(红色波浪线,编译正常)

#ifndef __MYI2C_H
#define __MYI2C_H

// #include <stdint.h>                                                  // 第一种方法:避免 uint8_t 未定义报错
//"forcedInclude": ["C:\\Keil_v5\\ARM\\ARMCC\\include\\stdint.h"]       // 第二种方法:避免 uint8_t 未定义报错

void MyI2C_Init(void);
void MyI2C_Start(void);
void MyI2C_Stop(void);
void MyI2C_SendByte(uint8_t Byte);
uint8_t MyI2C_ReceiveByte(void);
void MyI2C_SendAck(uint8_t AckBit);
uint8_t MyI2C_ReceiveAck(void);

#endif

举例如下:

{
    "configurations": [
        {
            "name": "Target 1",
            "includePath": [
                "c:\\Gitee\\stm32\\00_三刷\\10-1 软件I2C读写MPU6050\\Start",
                "c:\\Gitee\\stm32\\00_三刷\\10-1 软件I2C读写MPU6050\\Library",
                "c:\\Gitee\\stm32\\00_三刷\\10-1 软件I2C读写MPU6050\\User",
                "c:\\Gitee\\stm32\\00_三刷\\10-1 软件I2C读写MPU6050\\System",
                "c:\\Gitee\\stm32\\00_三刷\\10-1 软件I2C读写MPU6050\\Hardware",
                "C:\\Keil_v5\\ARM\\ARMCC\\include",
                "C:\\Keil_v5\\ARM\\ARMCC\\include\\rw"
            ],
            "defines": [
                "USE_STDPERIPH_DRIVER",
                "__CC_ARM",
                "__arm__",
                "__align(x)=",
                "__ALIGNOF__(x)=",
                "__alignof__(x)=",
                "__asm(x)=",
                "__forceinline=",
                "__restrict=",
                "__global_reg(n)=",
                "__inline=",
                "__int64=long long",
                "__INTADDR__(expr)=0",
                "__irq=",
                "__packed=",
                "__pure=",
                "__smc(n)=",
                "__svc(n)=",
                "__svc_indirect(n)=",
                "__svc_indirect_r7(n)=",
                "__value_in_regs=",
                "__weak=",
                "__writeonly=",
                "__declspec(x)=",
                "__attribute__(x)=",
                "__nonnull__(x)=",
                "__register=",
                "__breakpoint(x)=",
                "__cdp(x,y,z)=",
                "__clrex()=",
                "__clz(x)=0U",
                "__current_pc()=0U",
                "__current_sp()=0U",
                "__disable_fiq()=",
                "__disable_irq()=",
                "__dmb(x)=",
                "__dsb(x)=",
                "__enable_fiq()=",
                "__enable_irq()=",
                "__fabs(x)=0.0",
                "__fabsf(x)=0.0f",
                "__force_loads()=",
                "__force_stores()=",
                "__isb(x)=",
                "__ldrex(x)=0U",
                "__ldrexd(x)=0U",
                "__ldrt(x)=0U",
                "__memory_changed()=",
                "__nop()=",
                "__pld(...)=",
                "__pli(...)=",
                "__qadd(x,y)=0",
                "__qdbl(x)=0",
                "__qsub(x,y)=0",
                "__rbit(x)=0U",
                "__rev(x)=0U",
                "__return_address()=0U",
                "__ror(x,y)=0U",
                "__schedule_barrier()=",
                "__semihost(x,y)=0",
                "__sev()=",
                "__sqrt(x)=0.0",
                "__sqrtf(x)=0.0f",
                "__ssat(x,y)=0",
                "__strex(x,y)=0U",
                "__strexd(x,y)=0",
                "__strt(x,y)=",
                "__swp(x,y)=0U",
                "__usat(x,y)=0U",
                "__wfe()=",
                "__wfi()=",
                "__yield()=",
                "__vfp_status(x,y)=0"
            ],
            "intelliSenseMode": "${default}",
            "forcedInclude": [
                "C:\\Keil_v5\\ARM\\ARMCC\\include\\stdint.h"
            ]
        }
    ],
    "version": 4
}
posted @ 2026-04-03 17:23  Q&25  阅读(0)  评论(0)    收藏  举报