News for hackers. Stuff that matters.
Re:Conflating pointers with arrays: C's biggest mistake? (2009) by senatorobama on Sunday July 22, 2018 @05:15AM (#17585958)
Why is struct ip_weight padded.. is it to make it word aligned on 64-bit platforms?
Re:Conflating pointers with arrays: C's biggest mistake? (2009) by blattimwind on Sunday July 22, 2018 @05:28AM (#17585989)
in_addr_t is a 32 bit integer. On 64 bit archs this will usually result in a 32 bit padding for word alignment.
Re:Conflating pointers with arrays: C's biggest mistake? (2009) by bluecalm on Sunday July 22, 2018 @10:29AM (#17586923)
Padding is needed for two reasons: 8 bytes element need to start at multiple of 8 bytes address and to make the whole struct size multiple of the biggest member. This is needed for alignment once those structs are need to each other for example in an array.
Re:Conflating pointers with arrays: C's biggest mistake? (2009) by pandaman on Sunday July 22, 2018 @05:34AM (#17586002)
To align 'weight' member on its size.
Re:Conflating pointers with arrays: C's biggest mistake? (2009) by senatorobama on Sunday July 22, 2018 @06:51AM (#17586173)
so the pad will be before the 'weight' member in memory?
Re:Conflating pointers with arrays: C's biggest mistake? (2009) by tardo99 on Sunday July 22, 2018 @07:15AM (#17586217)