struct memory layout

J

joe

struct {
int x;
int y;
int z;
};

Does the ansi standard say anything about whether field z will be
stored at a higher memory address than x ?

Joe
 
V

Victor Bazarov

joe said:
struct {
int x;
int y;
int z;
};

Does the ansi standard say anything about whether field z will be
stored at a higher memory address than x ?

Yes, it does, and yes, it will.

V
 
E

EventHelix.com

struct {
 int x;
 int y;
 int z;

};

Does the ansi standard say anything about whether field z will be
stored at a higher memory address than x ?

Joe

The standard does say that x, y and z will be stored in the specified
order. Padding might be needed between the fields. This is
architecture dependent.

The following article has more details:
http://www.eventhelix.com/RealtimeMantra/ByteAlignmentAndOrdering.htm

--
EventStudio - http://www.Eventhelix.com/Eventstudio/
Sequence diagram based systems engineering tool
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top