cstructtypedefextern

extern vars and struct defined in other source file


Have two files with struct definitions. Header:

typedef struct _InputData InputData;
extern InputData input_data;

and source file:

struct _InputData{
    char const*modification_l;
    char const*amount_l;
    char const*units_l;
};
InputData input_data = {...};

When i try to use input_data from other source file it gives me "invalid use of incomplete typedef ‘InputData’". I think i understand why it happened, but how i can deal with it in the gracefullest way.


Solution

  • You have to define the complete structure in the header file. Otherwise there is no way to know what fields it have, i.e. it's incomplete.