struct X
{
};
struct Y
{
int i;
float f;
char buffer[20];
};
struct X *pX;
struct Y *pY;
// ...
pX = (struct X *)pY;
Afterall, struct X is just a type, as is struct Y. The fact
that there is no member field in X is not important, at all.
Note that even for named structures with no member fields, C and C++ still enforces type checking. Each named structure is unique. This means that the following code will generate an error:
struct X {};
struct Y {};
struct X *pX;
struct Y *pY;
// ...
pX = pY;