From: Wolfgang Denk Date: Tue, 26 Oct 2010 23:31:48 +0200 Subject: [U-Boot] [PATCH 3/3 v2] Replace CONFIG_SYS_GBL_DATA_SIZE by auto-generated value In-Reply-To: <20101026211821.GA2528@morgana.i.gnudd.com> References: <20101026211233.BB83B152451@gemini.denx.de> <20101026203811.D0EF1152451@gemini.denx.de> <1288104730-25651-1-git-send-email-wd@denx.de> <1288101601-24871-4-git-send-email-wd@denx.de> <20101026195429.GA1349@morgana.i.gnudd.com> <20101026205756.GA2139@morgana.i.gnudd.com> <20101026211821.GA2528@morgana.i.gnudd.com> Message-ID: <20101026213148.89A6F152451@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Alessandro Rubini, In message <20101026211821.GA2528@morgana.i.gnudd.com> you wrote: > > Is it guaranteed (I mean by the C standard) that the alignment of a > > struct (which affects only the possible start address) also has effect > > on the sizeof() for that struct, in the sense that sizeof() is > > guaranteed to be a multiple of that alignment requirement? > > Yes. Because if you make an array, all of them must be aligned, and > the size of an array is a multiple of sizeof(array_item). While > alignment is not in the standard, the sizeof/array relationship is. I am not convinced, as we don't have an array context here. > It's in C99 draft (http://busybox.net/~landley/c99-draft.html) > > 6.5.3.4 The sizeof operator > > #6 > > EXAMPLE 2 Another use of the sizeof operator is to compute the > number of elements in an array: > sizeof array / sizeof array[0] I don't see that with struct foo x; struct foo y[N]; we have a guarantee that sizeof(x) == sizeof(y[0]). Maybe I'm just paranoid... Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Until you walk a mile in another man's moccasins, you can't imagine the smell.