I am trying to copy a structure x into another structure y that has x nested.
For example:
#define DATASIZE 128
typedef struct {
char data[DATASIZE];
} x_TYPE;
typedef struct {
int number;
x_TYPE nested_x;
enum boolean error;
} y_TYPE;
/* ---- Values for the type field in xy_union ---- */
#define TYPE_IS_X 0;
#define TYPE_IS_Y 1;
typedef struct {
union { /* structure containing x_object */
x_TYPE x_object; /* or y_object as a union */
y_TYPE y_object;
} u;
int type; /*One of: TYPE_IS_X, TYPE_IS_Y */
} XY_TYPE;
This is how I currently copy:
copyXY(XY_TYPE *xx)
{
XY_TYPE *yy; /* assume this is allocated already */
yy->u.y_object.nested_x = *xx; /* ERROR LINE */
return 0;
}
I get a compiler error of: error: incompatible types when assigning to type ‘x_TYPE’ from type ‘XY_TYPE’.
Please let me know if anyone knows why this occurs.
Is this what you are looking for?
It isn’t clear from the question what you are trying to do.