what is a word-length boundary?

0

I'm reading this article:

http://en.wikipedia.org/wiki/Struct_%28C_programming_language%29

And it states the following:

"The C struct directly corresponds to the Assembly Language data type of the same use, and both reference a contiguous block of physical memory, usually delimited (sized) by word-length boundaries. Language implementations which could utilize half-word or byte boundaries (giving denser packing, using less memory) were considered advanced in the mid-eighties."

What is a word-length boundary?

JohnMerlino

Posted 2014-04-26T20:04:41.950

Reputation: 257

Answers

0

Some architectures will align data in a given word length (two bytes, four bytes, etc) thus defining this structure in C:

struct sample {
  int a;
  char b;
}

Could end up with a size of eight bytes even if you expect it to be only five (four bytes for a and one for b). This ensure every member starts in a position multiple of 4. And it depend on the architecture where compilation occurs. If ever need to force packing you can do this:

#pragma pack(1)
struct sample {
  int a;
  char b;
}

drk.com.ar

Posted 2014-04-26T20:04:41.950

Reputation: 2 287