Archived

This topic is now archived and is closed to further replies.

Is it possible to make a union which behave much like a register?

This topic is 5111 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is it possible to make a union which behave much like a register? I mean, you could create, lets say XX, and then, after assigning a value to XX, we could get the lower and higher part of the value, with XL and XH. I mean: XX = 0x1234; XL = 0x34; XH = 0x12; From what I understand about unions, I would go to somethin like this: typedef union { unsigned int XX; unsigned char XL; } reg_t; reg_t lol; lol.XX = 0x1234; This way, lol.XL would get the 0x34, but how can I create a variable inside the union that could get the 0x12? (case that is possible)

Share this post


Link to post
Share on other sites