Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!mailrus!cornell!uw-beaver!blake!keffer From: keffer@blake.acs.washington.edu (Thomas Keffer) Newsgroups: comp.lang.c++ Subject: ?-tion on sizeof classes Keywords: sizeof structure boundaries Message-ID: <2425@blake.acs.washington.edu> Date: 16 Jun 89 03:10:40 GMT Reply-To: keffer@ocean.washington.edu Organization: University of Washington, Seattle Lines: 28 On p. 54 of The Bible BS says "It is not possible to compute the size of an object of a structure type simply as the sum of its members. The reason for this is that many machines require [certain objects to] be allocated on architecture - dependent boundaries." Aside from this cavaet, is there any other reason why the size of an object might not be the sum of its members? Suppose I was willing to check for the alignment problem. Could I then be assured that the whole is the sum of its parts, or will there ever be a "hidden" member, put in there by the compiler? The reason I ask is that it would sure be nice if I could assume sizeof(Complex) == 2*sizeof(double) because this is what a LOT of FORTRAN routines assume. FFT routines, for example, routinely treat an N point complex vector as a 2N real vector. -tk --- Dr. Thomas Keffer | Internet: keffer@sperm.ocean.washington.edu School of Oceanography | BITNET: keffer%sperm.ocean.washington.edu@UWAVM Univ. of Washington, WB-10 | uucp: uw-beaver!sperm.ocean.washington.edu!keffer Seattle, WA 98195 | Telemail: T.KEFFER/OMNET (206) 543-6455