将结构体中的部分成员定义在其他文件中

BeInclude.h

 

#ifdef _BEINCLUDE_H_
int nBeInclude;
#endif

 

 

DefineStruct.h

 

 

typedef struct{
 int nDef;
 #define _BEINCLUDE_H_
 #include "BeInclude.h"
 #undef _BEINCLUDE_H_
}TEST;

 

 

引用:

#include  "DefineStruct.h"

void main()
{
 TEST  testA;
 testA.nDef = 1;
 testA.nBeInclude = 2;

 printf("testA.nDef = %d,testA.nBeInclude = %d/n",
  testA.nDef,
  testA.nBeInclude);
}

你可能感兴趣的:(struct)