TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: rowan crowe
from: David Nugent
date: 1995-07-09 17:46:20
subject: structure alignment

rc> Can I have a clarification: is alignment part of ISO C,
 rc> or just a handy addition that is supported by a few
 rc> compilers?

The lack of any *assumption* as to any specific alignment is part of ISO C.
And byte and word order, for that matter - alignment is a trivial matter
compared with endian-ness.

You problem, I think, is seeing this from a "PC" point of view.
While it might be occasionally `inconvenient', C was written to be as
portable as possible across all (or at least most) CPU architectures and
operating environments. As I've previously said here, alignment is
*necessary* on some architectures.

From the PC point of view, compiler vendors provide 1) the ability to force
a specific alignment, if one is required, and 2) a quality implementation
warns the programmer about structs with structure alignment dependancies
which use the default (compiler switch dependant) alignment.

---
* Origin: Unique Computing, Melbourne, Australia (3:632/348)
SEEN-BY: 50/99 620/243 623/630 632/103 348 998 633/371 634/384 388 635/301
SEEN-BY: 635/502 503 544 727 636/100 639/100 711/401 409 410 430 510 807 808
SEEN-BY: 711/809 932 934 712/515 713/888 714/906 800/1 7877/2809
@PATH: 632/103 348 635/503 50/99 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.