Quantcast
Channel: C Variable has incomplete initializer - Stack Overflow
Viewing all articles
Browse latest Browse all 3

C Variable has incomplete initializer

$
0
0

I am trying to make a struct with a default value, as described here: Default values in a C Struct. However, I have this C code, inside a header file:

/* tokens.h */
typedef struct {
    char *ID;
    char *KEY;
    char *TYPE;
} tokens;

const struct tokens TOKENS_DFLT = {
    "id",
    "key",
    "type"
};

And I am getting an error on line 7 saying:

error: variable 'TOKENS_DFLT' has initializer but incomplete type

Can anyone please explain to me what this problem is and how I can fix it and prevent it in the future?


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images