Like this. In the fileA.c file I have
typedef struct MY_STRUCT { int A; int B; int C; }MY_STRUCT; MY_STRUCT Data; int function(MY_STRUCT *params) { int varA, varB, varC; varA = params->A; varB = params->B; varC = params->C; }
And I need to populate the structure elements from another routine, for example, "fileB.c", which contains the following:
extern MY_STRUCT Data; int function(MY_STRUCT *params); void userMain(void) { Data.A = 1254; Data.B = 5426; Data.C = 1236; function(&Data); }
But I get an error message:
"[Error] fileB.c E208: syntax error - token"; "inserted before" data
And if I get to the error, the compiler will take me to the declaration "extern MY_STRUCT Data;"
So my question is how to execute this function? I mean, how to populate the structure elements from another function in a different file than the file in which I declared the structure?
source share