B
Bryan Parkoff
I hate using struct / union with dot between two words. How can I use
one word instead of two words because I want the source code look reading
clear. three variables are shared inside one variable. I manipulate to
change 8-bit data before it causes to change 16-bit data and 32-bit data.
For example.
union
{
struct _Byte
{
U_BYTE AAL;
U_BYTE AAH;
} Byte;
struct _Word
{
U_WORD AAW;
} Word;
struct _DWORD
{
U_DWORD AA;
} DWord;
};
int main()
{
// I hate dot between 2 words.
Byte.AAL = 0xFF;
Byte.AAH = 0x20;
Byte.AAL += 0x0A;
Byte.AAH += 0x01;
Word.AAW += 0xFF;
DWord.AA += 0xFFFF;
// It is easy reading variable inside struct / union.
AAL = 0xFF;
AAH = 0x20;
AAL += 0x0A;
AAH += 0x01;
AAW += 0xFF;
AA += 0xFFFF;
one word instead of two words because I want the source code look reading
clear. three variables are shared inside one variable. I manipulate to
change 8-bit data before it causes to change 16-bit data and 32-bit data.
For example.
union
{
struct _Byte
{
U_BYTE AAL;
U_BYTE AAH;
} Byte;
struct _Word
{
U_WORD AAW;
} Word;
struct _DWORD
{
U_DWORD AA;
} DWord;
};
int main()
{
// I hate dot between 2 words.
Byte.AAL = 0xFF;
Byte.AAH = 0x20;
Byte.AAL += 0x0A;
Byte.AAH += 0x01;
Word.AAW += 0xFF;
DWord.AA += 0xFFFF;
// It is easy reading variable inside struct / union.
AAL = 0xFF;
AAH = 0x20;
AAL += 0x0A;
AAH += 0x01;
AAW += 0xFF;
AA += 0xFFFF;