Variables in functions ... What is best?

pico:
"A union may be thought of as a structure all of whose members begin at offset 0 and whose size is sufficient to contain any of its members. At most one of the members can be stored in a union at any time."

So:

union myunion {
int var_a;
int var_b;
float var_c;
} uval;

will allow (actually, force) vars var_a, var_b and var_c to share the same memory address.

uval.var_a and uval.var_b will be typed as ints, while uval.var_c will be typed as a float.

Sometimes you just gotta tell the compiler who's boss!

That is not the same as the optimisation I pointed out, what about two variables of different sizes? Your optimisation causes sub-optimal performance.

Also its not forcing anything, the names are aliases to a single type. Your example is in violation of the specifications if you write to one member then read another ( strict aliasing rule ), and becomes unsafe once you start using non-trivial members, not to mention trap representations.

Once you have to use unions for much other than sign extension, minimum type sizing, or handling c code, you could be explicitly adding 'undefined behaviour' to your code.