in .h:
typedef struct token_t TOKEN;
in .c:
#include "token.h"
struct token_t
{
char* start;
int length;
int type;
};
in main.c:
#include "token.h"
int main ()
{
TOKEN* tokens; // here: ok
TOKEN token; // here: Error: incomplete type is not allowed
// ...
}
The error I get in that last line:
Error: incomplete type is not allowed
What's wrong?
An incomplete class declaration is a class declaration that does not define any class members. You cannot declare any objects of the class type or refer to the members of a class until the declaration is complete.
This error usually means that you are trying to follow a pointer to a class, but the compiler did not find the definition of that class (it found a declaration for the class, so it is not considered an unknown symbol, but it did not find a definition, so it is considered an incomplete class).
You need to move the definition of the struct
into the header file:
/* token.h */
struct token_t
{
char* start;
int length;
int type;
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With