2

I am encountering the following problem in C: I declare a typedef for a struct in a headerfile ("mep.h")

#ifndef MEP_H
#define MEP_H

typedef struct Mep_tag Mep;
<other stuff declared here>

#endif

I use another headerfile ("mep_types.h") that includes "mep.h", defines the struct "Mep_tag" and uses the "Mep" type name:

#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

For some reason when this compiles, I get the following error: "mep_types.h: error: unknown type name "'Mep'".

However, if in the "mep.h" I place the typedef outside the ifndef guard like this...

typedef struct Mep_tag Mep;

#ifndef MEP_H
#define MEP_H

<other stuff declared here>

#endif

... the "Mep" type name is visible in "mem_types.h".

Might someone know how this could happen?

4

0 回答 0