Hardly at all. The VB Variant datatype is actually a union in the C/C++ backend.
There are some tricky float/int conversion optimizations for high-performace/low-accuracy apps (like games) that involve a union like this:
Code:
typedef union {
float f;
int i;
} FICONVERT;
You can read about this in the Game Programming Gems series.
Then there's the LARGE_INTEGER and ULARGE_INTEGER unions in the Win32 API, which are unions of a 64-bit integer and a struct of two 32-bit integers, to support 64-bit numbers on machines which don't support them. Used to retrieve free disk space for example.
There were the register unions back in the DOS days. They were used to store the CPU register state, and as CPU registers partially overlap a union is the perfect choice.
Code:
struct general_purpose
{
union {
long eax;
short ax;
struct {
char al;
char ah;
};
};
union {
long ebx;
short bx;
struct {
char bl;
char bh;
};
};
union {
long ecx;
short cx;
struct {
char cl;
char ch;
};
};
union {
long edx;
short dx;
struct {
char dl;
char dh;
};
};
};