I have the following data types declaration.
typedef struct{
int aa;
}A;
typedef struct{
int bb;
}B;
typedef struct{
union {
A a;
B b;
}*D;
int other;
}myType;
//Now I want to pass the array "D" and the variable "other" to a function
// that will use them to construct "myType"
// How can I pass D as parameter? what whill be its type?
//I want to have a function like the following with "?" filled.
callFunction(? d, int other){
//construct "myType"
myType typ;
typ.D = d;
typ.other = other;
}
I have tried to declare the union outside the “mytype” struct, and then use D* d; in “mytype” struct
in that case I am having this error
error: expected specifier-qualifier-list before ‘D’
The code is as follows:
//struct A and B are declared above
union {
A a;
B b;
}D;
typedef struct{
D* d;
int other;
}myType;
Any help will be appreciable,
thanks.
or
The body of
callFunctionwill be the same for both: