Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Order of structure members in memory

Reply
Thread Tools

Order of structure members in memory

 
 
Christopher Benson-Manica
Guest
Posts: n/a
 
      09-26-2004
Are the members of a struct guaranteed to have ascending memory
addresses?

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
 
Reply With Quote
 
 
 
 
Ben Pfaff
Guest
Posts: n/a
 
      09-26-2004
Christopher Benson-Manica <(E-Mail Removed)> writes:

> Are the members of a struct guaranteed to have ascending memory
> addresses?


Yes.
--
"A lesson for us all: Even in trivia there are traps."
--Eric Sosman
 
Reply With Quote
 
 
 
 
Jack Klein
Guest
Posts: n/a
 
      09-26-2004
On Sun, 26 Sep 2004 19:15:05 +0000 (UTC), Christopher Benson-Manica
<(E-Mail Removed)> wrote in comp.lang.c:

> Are the members of a struct guaranteed to have ascending memory
> addresses?


Yes, always in C.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
 
Reply With Quote
 
Christopher Benson-Manica
Guest
Posts: n/a
 
      09-26-2004
Jack Klein <(E-Mail Removed)> spoke thus:

> Yes, always in C.


Just for my edification, what is the chapter and verse? Thanks...

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
 
Reply With Quote
 
Eric Amick
Guest
Posts: n/a
 
      09-26-2004
On Sun, 26 Sep 2004 20:07:47 +0000 (UTC), Christopher Benson-Manica
<(E-Mail Removed)> wrote:

>Jack Klein <(E-Mail Removed)> spoke thus:
>
>> Yes, always in C.

>
>Just for my edification, what is the chapter and verse? Thanks...


In C99, it's 6.7.2.1, paragraph 13.

--
Eric Amick
Columbia, MD
 
Reply With Quote
 
Derrick Coetzee
Guest
Posts: n/a
 
      09-26-2004
Christopher Benson-Manica wrote:
> Jack Klein <(E-Mail Removed)> spoke thus:
>>> Christopher Benson-Manica wrote:
>>> Are the members of a struct guaranteed to have ascending memory

addresses?
>>
>>Yes, always in C.

>
> Just for my edification, what is the chapter and verse? Thanks...


In C90, it's 6.5.2.1, verse 11:

"Within a structure object, the non-bit-field members and the units in
which bit-fields reside have addresses that increase in the order in
which they are declared."

This is a bit vague, since you don't technically declare the units
bit-fields reside in (but rather the bit-fields that go in them, but
adjacent bits fields do go into each unit). Bit-field members within a
unit are in implementation-defined order.
--
Derrick Coetzee
I grant this newsgroup posting into the public domain. I disclaim all
express or implied warranty and all liability. I am not a professional.
 
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
class members vs instance members hdixon Python 3 07-09-2006 06:56 PM
Memory allocation in Structure to Structure pra_ramli@rediffmail.com C++ 2 03-09-2006 05:51 AM
Difference between static final members and final static members(if any)? JFCM Java 4 02-07-2006 11:32 AM
Templates: Members Vs. non-members Dave C++ 3 08-10-2004 11:23 AM
Can nested class members access private members of nesting class? CoolPint C++ 8 12-14-2003 02:30 PM



Advertisments