我创建了两个类“DEVICE_s”和“DEVICE_SET_s”,如下所示:
Device_Manager.h
typedef struct DEVICE_s DEVICE_s;
typedef struct DEVICE_SET_s DEVICE_SET_s;
Device_Manager.c
struct DEVICE_s
{
uint32_t IP;
TYPE_e Type;
METHOD_e Method;
GROUP_RULE_e GroupRule;
char Name[NAME_SIZE];
};
struct DEVICE_SET_s
{
uint8_t Total;
uint8_t Used;
uint8_t Available;
DEVICE_s Set[SET_SIZE];
};
DEVICE_s Instance;
DEVICE_SET_s Objects;
因为我将这两个类放在同一个文件中,所以操作变量“Instance”和“Objects”的所有函数都放在这个文件中。
考虑到模块化,我认为这种方式不好,所以我想创建另一个源文件来单独管理类“DEVICE_SET_s”,就像:
DeviceSet_Manager.h
typedef struct DEVICE_SET_s DEVICE_SET_s;
DeviceSet_Manager.c
#include "Device_Manager.h"
#include "DeviceSet_Manager.h"
struct DEVICE_SET_s
{
uint8_t Total;
uint8_t Used;
uint8_t Available;
DEVICE_s Set[SET_SIZE]; //Oops! Incomplete Type Is Not Allowed
};
但是,就 DeviceSet_Manager.c 而言,“DEVICE_s”类是不可见的(不是完整的类型)。
我该如何解决?谢谢