Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!decwrl!pyramid!csg From: csg@pyramid.pyramid.com (Carl S. Gutekunst) Newsgroups: comp.arch Subject: Re: RISC data alignment Message-ID: <13675@pyramid.pyramid.com> Date: 24 Jan 88 01:09:06 GMT References: <2635@calmasd.GE.COM> Reply-To: csg@pyramid.UUCP (Carl S. Gutekunst) Organization: Pyramid Technology Corp., Mountain View, CA Lines: 26 In article <2635@calmasd.GE.COM> gjo@calmasd.UUCP (Glenn Olander) writes: >I believe that many RISC machines require data to be aligned on a natural >boundary, e.g. longwords must be referenced on a 4-byte boundary. While this is true of practically all RISC and RISC-like designs, it is also true of nearly all other architectures, too. The number of architectures that allow totally random positioning of objects is quite small, and I daresay that C programmers have gotten totally spoiled by them. (I did not say installed base! Number of *architectures.* That means the VAX counts as 1.) >...then it would seem to also be true that a C structure could have different >lengths, depending on whether it was compiled on a RISC or non-RISC machine. >...if that C structure were written out to a file, it could only be read >properly by a machine of the same type as that which wrote it. C structures compiled on *any* two different architectures are likely to be different lengths. Think of all the things that can be different besides the alignment: 16 or 32 bit ints, size of floats, format of floats. Then add byte order if you really want to confuse things. >If I create a file on a Sun/4 will I be able to read it on a Sun/3? Under the terms you described, no. Binary data files are simply not portable. So use ASCII text files.