Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: struct padding question Date: Sat, 01 Apr 2017 12:00:00 -0700 Organization: None to speak of Lines: 22 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="36ef018e15eba2e585ee9d4de7c886c9"; logging-data="20150"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+pIfJt8QrZkJupZgRDaexs" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:xX+yAwgm0pJeVdnOZexTAa3GaYE= sha1:ULfBSGLw3yyAfI0fedlgtU5GUGw= Xref: csiph.com comp.lang.c:107597 Robert Wessel writes: [...] > There have been implementations of, 10-byte (80-bit), x86 long double > which have 2, 4, 8 and 16 byte alignment requirements. > > For example, amongst compilers actually supporting the 80-bit type, MS > and Borland's 16-bit compilers use 2-byte alignment, several 32-bit > (typical x86 GCC, for example) compilers use 4B alignment, Watcom uses > 8B in both 16 and 32-bit versions, and most *nix compilers on 64B use > 16B alignment, as does ICC on Windows in both 32 and 64B modes). > > *Not* intended to be an exhaustive list. The size of a type must be a whole multiple of its alignment; arrays cannot have gaps between elements. If a 10-byte floating-point type requires 4-byte alignment, it must be padded to at least 12 bytes. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"