| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Bob`s questi |
Sun 2003-08-03 22:31, Jasen Betts (3:640/1042) wrote to Bill Birrell:
JB> I have a question: - something that came up in the C++ echo recently
JB> Given
JB> typedef struct moo
JB> {
JB> int foo;
JB> char bar;
JB> } moo;
JB> is sizeof(moo) * 100 always the same as sizeof( moo[100] )
moo[100] is not valid, but I think you mean:
moo amoo[100];
JB> in other words does sizeof() include any slack space required for
JB> alignment.
Structure padding is between structure members, not array elements, eg.
/* four byte alignment, four byte ints */
amoo =
{
{ /* amoo[0] */ 424242, 'A' /* followed by 3 bytes of padding */ },
{ /* amoo[1] */ 848484, 'B' /* followed by 3 bytes of padding */ }
}
But NOT:
amoo =
{
{ /* amoo[0] */ 424242, 'A' },
/* 3 bytes padding outside the struct - impossible */
{ /* amoo[1] */ 848484, 'B' }
/* another 3 bytes padding outside the struct - impossible */
}
I hope that makes sense...
-- mail{at}ozzmosis.com
--- timEd/FreeBSD 1.11.b1
* Origin: Blizzard of Ozz, Mt Eliza, Melbourne, Australia (3:633/267)SEEN-BY: 633/267 270 @PATH: 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.