Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > struct memory padding

Reply
Thread Tools

struct memory padding

 
 
peter koch
Guest
Posts: n/a
 
      01-22-2007

peter koch wrote:
[snip]
> The statements in the link given in a previous post were not entirely
> accurate.

[snip]
And some very good explanations have been given elsewhere in this
thread.

/Peter

 
Reply With Quote
 
 
 
 
simonp@nospam.com
Guest
Posts: n/a
 
      01-22-2007
peter koch <> wrote:
>
> wrote:
>> Thanks so much. Padding of the struct will bring it up to the
>> next multiple of the word size, eg. 32bit/4byte
>>
>> Cheers,
>> Simon
>>
>> --
>> Stupendous Tales
>> www.stupendoustales.com
>> Speculative Fiction, Pulp Dreams

> The statements in the link given in a previous post were not entirely
> accurate. Basically, padding occurs because the underlying CPU either
> requires or prefers a given alignment when reading/writing fundamental
> types. This is not necesarrily the same size as the word size. One
> example is the newer x86 processors where an optimal reading of doubles
> requires the double to be aligned on an 8 byte boundary. Thus
> struct s { char c; double d; } will most likely occupy 16 bytes.
>
> /Peter
>


My teacher has given me no background such as this.

This is the 2nd course in the 2 course intro to programming. The
1st course used to be C++, but now it is Java, so the low level
programming techniques that used to be covered in the 1st course
are lost. But the teacher has not adjusted the 2nd course
appropriately. Maddening. Though I guess its always better to
learn on your own.

Cheers
Simon

--
Stupendous Tales
www.stupendoustales.com
Speculative Fiction, Pulp Dreams
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can *common* struct-members of 2 different struct-types, that are thesame for the first common members, be accessed via pointer cast to either struct-type? John Reye C Programming 28 05-08-2012 12:24 AM
struct padding ??? vikas talwar C Programming 3 05-31-2008 10:06 PM
Padding bits and struct assignment Hallvard B Furuseth C Programming 5 12-27-2006 10:19 PM
struct padding edware C Programming 9 04-27-2006 12:40 AM
struct my_struct *p = (struct my_struct *)malloc(sizeof(struct my_struct)); Chris Fogelklou C Programming 36 04-20-2004 08:27 AM



Advertisments