Event union...oh i get it!

Fellow humans,
Ok, I think I understand. So referencing event.type is, really, just
a user-friendly reference to a specific place in memory. And, because
a union puts everything in the same memory space, refering to
event.button.type refers to the exact same space in memory. I have a
copy of The C Programming Language, and now I understand why “it’s the
programmer’s responsibility” to keep track of what is in a union: man,
the power of C!!

On a side note, I see why people get so frustrated with C at times…I
imagine an innapropriate reference to a union member could be a
debugging nightmare.

Thanks soooo much for your help!!!

Peace,
=Pete=

At 10:59 PM 10/20/02 +0000, you wrote:

Fellow humans,
Ok, I think I understand. So referencing event.type is, really, just
a user-friendly reference to a specific place in memory. And, because

Everything in C is a user-friendly reference to a specific place in memory.

Except for the things that are unfriendly references to a specific place in
memory.

On a side note, I see why people get so frustrated with C at times…I
imagine an innapropriate reference to a union member could be a
debugging nightmare.

To put it mildly, yes. :slight_smile:

Although when done correctly, as in SDL, something like this is an elegant
solution to the problem.