Peter Malfiz
Peter Malfiz

Reputation: 41

Can a pointer in C be the Ident of a StructureTypeDeclaration?

What would be the tagName and the Ident of the following Declaration?

typedef struct element *list;
struct element {int value; list next};

Would it be possible to declare it like this:

typedef struct element {int value; list next} *list;

Upvotes: 0

Views: 50

Answers (1)

Unmitigated
Unmitigated

Reputation: 89224

The second version does not work because list is not defined at that point. You would need to explicitly specify the type as struct element*.

typedef struct element {int value; struct element* next;} *list;

Upvotes: 2

Related Questions