在a.h中:

定义了,

struct ABC
{
  short a;
  short b;

  ```
};


在a.c中(#include "a.h"):

声明了,

struct ABC stcABC;

在b.c中想引入外部结构体stcABC,

则首先在b.c中#include “a.h”。

然后声明:

extern struct ABC stcABC;

即可,或者:

若不想在b.c中#include“a.h”,

则需在b.c中将struct ABC定义重新写一遍,

再声明,

extern struct ABC stcABC;

也可以。

 

相关文章:

  • 2022-12-23
  • 2021-10-19
  • 2022-12-23
  • 2021-12-18
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-05
  • 2019-03-05
  • 2022-12-23
  • 2021-08-30
  • 2021-06-13
相关资源
相似解决方案