Rimantas Radžiūnas
Rimantas Radžiūnas

Reputation: 257

Typedef usage from one header file in second header file

Basically, I need to have typedef in one header file and use it on another header.

myType.h:

#ifndef deque_H
#define deque_H
#include "deque.h"

typedef int intDef;

#endif

deque.h:

#ifndef deque_H
#define deque_H
#include "myType.h"
typedef struct dequeNode *link;
struct dequeNode{
    intDef data;
    link next;
    //count
};
#endif

I want to use intDef in deque.h, but I get project error \deque.h|6|error: unknown type name 'intDef'|

Does anybody have a clue what's wrong? myType.h is in the same project.

Upvotes: 1

Views: 535

Answers (1)

Michał Szydłowski
Michał Szydłowski

Reputation: 3419

You prevent your myType.h from ever being executed, since you use the same flag as in the other file. You need to choose any other symbol and check if it's defined:

#ifndef myType_H
#define myType_H

typedef int intDef;

#endif

Upvotes: 2

Related Questions