I have a struct defined inside capi_utils.h that looks like the following:
#ifndef _CAPI_UTILS_H_
# define _CAPI_UTILS_H_
...
struct ScalarVariable{
char name[63];
float value;
uint8_T DataID;
char type[50];
};
...
#endif
Inside of capi_utils.c I tried creating a variable to hold the struct like this
struct ScalarVariable sVariable;
Which only produces an error when I try setting a value inside the struct like this:
sVariable.name = paramName;
Error message is:
capi_utils.c:27: error: invalid use of undefined type `struct ScalarVariable'
What am I doing wrong?
EDIT 1:
I just had to include capi_utils.h. Didn't think I had to because I had understood source files and headers different for some reason.
EDIT 2:
To clarify, I even got errors when trying to set DataID, not only the array.
void GetValueFromAdress(const char_T* paramName,
void* paramAddress,
uint8_T slDataID,
unsigned short isComplex,
uint_T* actualDims,
uint_T numDims,
real_T slope,
real_T bias) {
sVariable.DataID = slDataID;
}
Would produce error: invalid use of undefined type 'struct ScalarVariable'
capi_utils.hinsidecapi_utils.c^^'namefield is an array. SosVariable.name = paramName;is wrong.=, simple as that. It has nothing to do with structs. Use strcpy.