Peter Pristaš Peter Pristaš - 17 days ago 10
C Question

Structure containing element which array contains same structures

typedef struct Sym_item{
char *name;
symbolType type;
char *data;
bool fce;
TList *args;
bool init;
tHTable *ptr_loctable; // .. this is conflicting
char *class_name;
bool isstatic;
struct Sym_item *nextptr;
}iSymbol;


typedef struct Hash_table{
iSymbol *ptr;
}Hash_item;


typedef Hash_item tHTable[Hash_table_size]; // .............. this is conflicting


I am using this structure
iSymbol
which contains a
tHTable
which is defined lately, but I need it that contains also the array of the symbols as this structure.

This says compiler:


error: unknown type name ‘tHTable’<br>
tHTable *ptr_loctable;


Answer

You should use forward declarations.

Before your iSymbol structure declaration, declare the other structure:

struct tHTable;

You do not have to write all of it's properties, as this is only a forward declaration.