memory alignment

A

Ahn Jung Hoon

Hello.

During anylizing the source code,

I found the difficult code.. ( u8:0; u8:8; u8:0; )

I don't understand this code..

and I want to know that what i have to read to understand "momory alignment"..

/*
** =========================================================================
** Memory alignment tools
** =========================================================================
*/

#define MC_PCC_FILL_STRUCT1 u8:0; u8:8; u8:0; ???
#define MC_PCC_FILL_STRUCT2 u8:0; u8:8; u8:8; u8:0; ???
#define MC_PCC_FILL_STRUCT3 u8:0; u8:8; u8:8; u8:8; u8:0; ???

typedef struct aaa
{
t_MsgHeader MsgHeader;
u8 msg_param[MAX_LENGTH_OF_L3_MSG];
MC_PCC_FILL_STRUCT1
}bbb;
 
J

Jack Klein

Hello.

During anylizing the source code,

I found the difficult code.. ( u8:0; u8:8; u8:0; )

I don't understand this code..

and I want to know that what i have to read to understand "momory alignment"..

/*
** =========================================================================
** Memory alignment tools
** =========================================================================
*/

#define MC_PCC_FILL_STRUCT1 u8:0; u8:8; u8:0; ???
#define MC_PCC_FILL_STRUCT2 u8:0; u8:8; u8:8; u8:0; ???
#define MC_PCC_FILL_STRUCT3 u8:0; u8:8; u8:8; u8:8; u8:0; ???

typedef struct aaa
{
t_MsgHeader MsgHeader;
u8 msg_param[MAX_LENGTH_OF_L3_MSG];
MC_PCC_FILL_STRUCT1
}bbb;

This code was written by one of two programmers:

1. One with a very specific low-level problem that had to be dealt
with this way, and was very familiar with the characteristics of the
compiler and the underlying hardware.

2. One who was not very smart, at least not as smart as he/she
thought he/she was.

In either case it is extremely non-portable.

As to what :0 does, look up bit-fields in any competent book on C.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top