In C if I have
typedef struct
{
Token_type type;
Token_data data;
} Token_t;

typedef struct sitem {
char *key;
struct Token_t *token;
} item_t;

Why can't I do?

void insert(char *key, Token_t *data) {
item_t* new_item = malloc(sizeof (_item_t));
new_item->token = data;

}

@matrix it works after I resolve the errors that gcc gives me, that it should be item_t and not _item_t, and that you need 'Token_t *token' and not 'struct Token_t *token'. The latter case because you're using the typedef
Sign in to participate in the conversation
Game Liberty Mastodon

Mainly gaming/nerd instance for people who value free speech. Everyone is welcome.