结构体定义后跨文件使用

在a.h 中声明

typedef struct 
{
    uint16_t Timer;
    uint8_t Timer_Flag;

} Struct_A;

在b.h 中声明

#include "a.h"

typedef struct 
{
    Struct_A m_a;

} Struct_B;

在b.C 中

#include "b.h"

    Stcuct_B b = {0};

void Test(void)
{


//none

}

 

 

编译错误为

..\\APP\b.h(33): error:  #5: identifier "Struct_A" is undefined

 

是不是a.h目录放的位置不对,include解析的时候没有找到a.h文件。

头文件的问题也怀疑过,多处调用还是不行

Struct_A是在a.h中定义的,而在结构体Struct_B里用到了Struct_A,所以也要调用a.h。