In C ++ / Qt / COM / DCOM there is the concept of "Variant", which roughly refers to the union, which also stores access to the connection. In C, you would have to provide something like this:
struct myCVariant { int variantType; union { char v1; int v2; float v3; } variantContent; void initVariant() { variantType = 0; } void setChar(char a) { variantType = 1; variantContent.v1 = a; } void setInt(int a) { variantType = 2; variantContent.v2 = a; }
You can copy some Variant implementation into some C ++ source code and port it to C. This is not exactly the same, but similar. And this is somewhat typical (at least at runtime).
EDIT: hexa beat me for a second. And note that I did not compile this, so my code may contain typos.
source share