[U-Boot] [PATCH 3/3 v2] Replace CONFIG_SYS_GBL_DATA_SIZE by auto-generated value

Alessandro Rubini rubini-list at gnudd.com
Tue Oct 26 23:18:21 CEST 2010


> 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.

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]

/alessandro


More information about the U-Boot mailing list