Re: why some members in the struct lost after struct type compulsion transformation
- From: lje9292004@xxxxxxxxxxxx
- Date: Tue, 15 Jul 2008 17:40:40 -0700 (PDT)
On 7月15日, 下午8时32分, Manish <manishh.gu...@xxxxxxxxx> wrote:
On Jul 13, 6:02 pm, lje9292...@xxxxxxxxxxxx wrote:
On 7月12日, 下午11时53分, ganyong <ganyong2...@xxxxxxxxx> wrote:
In fact, member in structures will be aligned according to your
complier configuration.
Use #pragma pack(?) to specify packing alignment for structure
explicitly.
In your case, #pragma pack(1) should be used.
Yes, Thank your reply. But in my code it didn't use the #pragma
pack(?), not the #pragma align 1.
I don't know the difference between them. why the code use the
following:
#if ((CPU_FAMILY==I960) && (defined __GNUC__))
#pragma align 1
#endif
Could you give me the answer?
Thank you!
The code snippet means that if your processor is I960 family and you
are compiling the c code using GNU C style coding the the data will be
byte alignment.
In the code snippet mentioned by you, the alignment is playing a major
role hence you are seeing the correct results..probably your code is
4bytes aligned. Can you tell me what processor you are using ?
Probably you can check the alignment by printing the size of the three
structures and then comparing.
All the best,
Manish Gupta
Thank you for your reply. I am using the pentium processor. And the
result is
NODE_T has 8 bytes!
ARC_T has 8 bytes!
LEAF_T has 8 bytes!
Yes, if my compiler is 4bytes aligned. Maybe it is right!
.
- Follow-Ups:
- References:
- why some members in the struct lost after struct type compulsion transformation
- From: lje9292004
- Re: why some members in the struct lost after struct type compulsion transformation
- From: lje9292004
- Re: why some members in the struct lost after struct type compulsion transformation
- From: ganyong
- Re: why some members in the struct lost after struct type compulsion transformation
- From: lje9292004
- Re: why some members in the struct lost after struct type compulsion transformation
- From: Manish
- why some members in the struct lost after struct type compulsion transformation
- Prev by Date: Re: The 9997th file specific DOSFS problem
- Next by Date: Re: why some members in the struct lost after struct type compulsion transformation
- Previous by thread: Re: why some members in the struct lost after struct type compulsion transformation
- Next by thread: Re: why some members in the struct lost after struct type compulsion transformation
- Index(es):
Relevant Pages
|