I think he has something like this in mind:
Code:
void foo()
{
union_of_every_known_type u;
u.dword = STD_OUTPUT_HANDLE;
u.handle = GetStdHandle(u.dword);
u.bool = SetConsoleMode(u.handle, ENABLE_LINE_INPUT);
if (!u.bool) {
u.dword = GetLastError();
/* etc. etc. */
}
In this particular case you could of course just write:
Code:
int foo()
{
if (!SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), ENABLE_LINE_INPUT)) {
DWORD error = GetLastError();
/* etc. */
}
Anyway, it looks unorthodix and not really generally usable strategy: it breaks down as soon you need two variables at the same time. There is also no good name for the union variable if it is used to represent anything, so should you need more than one the code will become quite messy/undescriptive. And how large are your functions on average, that it hurts so much declare a few variables?