Tuesday, 27 April, 2010

Issue with union

Recently, found the union in the 'C' code with 33 bits as a structure and an unsigned long as members.
There will be no problem in the memory allocation. But, what might be the problem with this type of data structure?
Issue we had was the union variable initialization. Usually, the unsigned long variable in union will be initialized to intialize the bits in structure. But, being 33 bits, one bit won't be initialized. A learning we had!!

2 comments:

Sankar said...

Can you paste the code ? It will be much easier to understand. Thanks. And keep up your nice series of posts.

thunderbyte said...

Post some sample code.