> > No, you can't cast a union or structure, but you can cast a pointer to one. > > Interesting. gcc *will* cast a union as long as one of the elements in > the union is of the same type of the object being cast. > > E.g.: > > union i_c { > int i; > char c; > }; > > ... > > unsigned int ui; > int i; > char c; > > ... > > c = ((union i_c)i).c; // not an error > c = ((union i_c)ui).c; // error > hmm... Definitely not ANSI standard behavior (but that is no surprise with GCC which contains many 'extensions' to the standard). I'd like to look at the generated code. I wonder if it is actually doing something like: union_i_c temp; temp.i = i; c = temp.c Also, can you use this as an LValue?: ((union i_c i).c = 'X'; Bob Ammerman RAm Systems -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu