I know what you mean though, I often have this is at the top of my scope blocks:
All just so you can print out the return code you got from the function! :(Code:short srcode = 0;
int ircode = 0;
long lrcode = 0;
QuantumPete
Printable View
Yes, it would be true for more complex cases when the compiler doesn't actually know what's going on. In a simple case, it would "understand" what's actually going on, and thus work out same as the "several variables" variant. I wrote a small example and Visual Studio .Net did sort out the union example to be the same as the one with a simple integer. However, I have seen compilers do "stupid" things when unions are involved.Quote:
Originally Posted by Matsp
--
Mats