struct - Error: storage size of 'c' isn't known -


i'm getting "error: storage size of 'c' isn't known" when try create variable "c" of struct called "struct car"

here code:

teste.h

#ifndef teste_h_included #define teste_h_included  typedef struct car car;  #endif // teste_h_included  

teste.c

#include <stdio.h> #include <stdlib.h> #include "teste.h"  struct car{     char name[20];     char model[20];  };  

main.c

#include <stdio.h> #include <stdlib.h> #include "teste.h" int main() {     car c;     return 0; }  

i can't figure out why i'm getting error... bet stupid... me?

the car structure on header file forward declaration, when it's included on main.c, has knowledge of forward declaration no clue of how it's defined (or in case, size of struct is). define struct on header file.

struct car {     char name[20];     char model[20]; };  

Popular posts from this blog