我在C中遇到以下问题:我在头文件(“mep.h”)中为结构声明了一个typedef
#ifndef MEP_H
#define MEP_H
typedef struct Mep_tag Mep;
<other stuff declared here>
#endif
我使用另一个包含“mep.h”的头文件(“mep_types.h”),定义结构“Mep_tag”并使用“Mep”类型名称:
#ifndef MEP_TYPES_H
#define MEP_TYPES_H
#include "mep.h"
#include "file1.h"
struct Mep_MsgElement_tag
{
const Mep * MsgCh;
};
struct Mep_tag
{
<stuff in here>
};
#endif
由于某些原因,当编译时,我收到以下错误:“mep_types.h:错误:未知类型名称”'Mep'“ .
但是,如果在“mep.h”中我将typedef放在ifndef后面,就像这样......
typedef struct Mep_tag Mep;
#ifndef MEP_H
#define MEP_H
<other stuff declared here>
#endif
...“mep”类型名称在“mem_types.h”中可见 .
可能有人知道这会怎么样?