KDev-PG-Qt and unions

Jonathan Schmidt-Dominé - Developer devel at the-user.org
Sat Apr 24 17:27:48 UTC 2010


Hi Milian!

struct C_Ast
{
	union
	{
		A_Ast *a;
		B_Ast *b;
	};
};
...
void visitC_Ast(C_Ast *c)
{
	if(c->a) // Like if(reinterpret_cast<A_Ast*>(c->b))
		...
	else if(c->b) // Like else if(reinterpret_cast<B_Ast*>(c->a)), of course 
both conditions are identical
		...
}
C++ won't care about the correct usage, unions are more or less short-forms 
for reinterpret-casts. The programmer has to care about the actual state of 
the union.

Jonathan
------------------------
Automatisch eingefügte Signatur:
Es lebe die Freiheit!
Stoppt den Gebrauch proprietärer Software!
Operating System: GNU/Linux
Kernel: Linux 2.6.31.8-0.1-default
Distribution: openSuSE 11.2
Qt: 4.6.3
KDE: 4.4.72 (KDE 4.4.72 (KDE 4.5 >= 20100415)) "release 4"
KMail: 1.13.2
http://gnu.org/
http://kde.org/
http://windows7sins.org/




More information about the KDevelop-devel mailing list