-1
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;
user3666197
  • 1
  • 6
  • 50
  • 92

2 Answers2

1

Consider not using typedef at all.

If you really want to use typedefs, consider defining the structs and typedefs independently, like so:

struct a { ... }; [...] typedef struct a a_t;

In case of forward declarations, that you need here, you have to do this split anyway.

struct Hash_table;

struct Sym_item {
    char *name;
    symbolType type;
    char *data;
    bool fce;
    TList *args;
    bool init;
    Hash_item *ptr_loctable[Hash_table_size];
    char *class_name;
    bool isstatic;
    struct Sym_item *nextptr;
};

struct Hash_table {
    struct Sym_item *ptr;
};

typedef struct Sym_item iSymbol;
typedef struct Hash_table Hash_item;
typedef Hash_item tHTable[Hash_table_size];
Bodo Thiesen
  • 2,476
  • 18
  • 32
0

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.

Amit
  • 5,924
  • 7
  • 46
  • 94