mockers
Would you like to react to this message? Create an account in a few clicks or log in to continue.

C: PAdding:PULKIT sir

3 posters

Go down

C: PAdding:PULKIT sir Empty C: PAdding:PULKIT sir

Post  ballu Sun Feb 01, 2009 9:16 pm

Why are staructures padded in multiples of 4
why not in multiples of 3 or 5 etc???
ballu
ballu

Posts : 58
Join date : 2009-02-01

Back to top Go down

C: PAdding:PULKIT sir Empty Re: C: PAdding:PULKIT sir

Post  $corpion Mon Feb 02, 2009 1:05 am

we can never say that structures are padded in multiples of 4...
padding is purely compiler dependent....
and compiler pads structures for faster execution of codes as padding allows to keep everythin in a proper fashion that helps in easy and fast access of data...
$corpion
$corpion

Posts : 25
Join date : 2009-01-30
Age : 37

Back to top Go down

C: PAdding:PULKIT sir Empty @scorpion

Post  ballu Mon Feb 02, 2009 1:59 am

right ...
but when we talk about gcc it does pad in multiples of 4
why only multiples of 4
ballu
ballu

Posts : 58
Join date : 2009-02-01

Back to top Go down

C: PAdding:PULKIT sir Empty Re: C: PAdding:PULKIT sir

Post  mnnit.rahul Wed Feb 04, 2009 2:06 am

Most modern CPUs perform best when fundemental types, like 'int' or 'float', are algined on memory boundarys of a particular size (eg. often a 4byte word on 32bit archs). Many architectures don't allow misaligned access or if they do inccur a performance penalty


/* copy paste mara hai but i am not confirmed whether this answer is satisfatory or not*/

mnnit.rahul

Posts : 51
Join date : 2009-02-01

Back to top Go down

C: PAdding:PULKIT sir Empty Re: C: PAdding:PULKIT sir

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum