Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #107593

Re: struct padding question

Path csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From tim prince <n8tm@aol.com>
Newsgroups comp.lang.c
Subject Re: struct padding question
Date Sat, 1 Apr 2017 14:41:38 -0400
Lines 24
Message-ID <ekaaj5F111tU1@mid.individual.net> (permalink)
References <ob062g$coi$1@dont-email.me> <ob07qd$if0$1@dont-email.me> <obon1p$4aj$1@dont-email.me>
Reply-To tprince@nospamcomputer.org
Mime-Version 1.0
Content-Type text/plain; charset=iso-8859-15; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net lyRciw9QBKwizkK0rUgrRwCt6UZjij3aXlV3ODP/XqgLjQ65G2
Cancel-Lock sha1:r6UtJnHF2Ifc53+nEeGJEi6AzqI=
User-Agent Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
In-Reply-To <obon1p$4aj$1@dont-email.me>
Xref csiph.com comp.lang.c:107593

Show key headers only | View raw


On 4/1/2017 1:15 PM, Noob wrote:
> On 23/03/2017 11:28, David Brown wrote:
>
>> struct data {
>> 	uint64_t ctr[6];	// 8-byte alignment, 8x6 data
>> 	long double mean;	// 16-byte alignment, 16-byte data
>> 	long double variance;	// 16-byte alignment, 16-byte data
>> 	long double * p_ptr;	// 8-byte alignment, 8-byte data
>>
>> 	// inserted by compiler...
>> 	uint64_t padding;	// 8-byte alignment, 8-byte data
>> };
>
> I think some platforms have sizeof(long double) = 10?
> (I have x86 in mind, with the 80-bit FP numbers.)
>

No, compilers which follow the precedent of gcc store 80-bit long double 
aligned to 12 bytes for x86 32-bit and 16 bytes for x86_64 64-bit (as 
Intel used to recommend before they began recommending not using that 
data type).  So it's non-portable to make assumptions about this.

-- 
Tim Prince

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

struct padding question MehdiAmini <atorrses@gmail.com> - 2017-03-23 14:28 +0430
  Re: struct padding question David Brown <david.brown@hesbynett.no> - 2017-03-23 11:28 +0100
    Re: struct padding question MehdiAmini <atorrses@gmail.com> - 2017-03-23 16:44 +0430
      Re: struct padding question jm.bourguet@gmail.com - 2017-03-23 05:30 -0700
      Re: struct padding question Keith Thompson <kst-u@mib.org> - 2017-03-23 08:45 -0700
    Re: struct padding question Noob <root@127.0.0.1> - 2017-04-01 19:15 +0200
      Re: struct padding question tim prince <n8tm@aol.com> - 2017-04-01 14:41 -0400
        Re: struct padding question supercat@casperkitty.com - 2017-04-02 09:15 -0700
          Re: struct padding question scott@slp53.sl.home (Scott Lurndal) - 2017-04-03 13:51 +0000
            Re: struct padding question supercat@casperkitty.com - 2017-04-03 07:48 -0700
              Re: struct padding question scott@slp53.sl.home (Scott Lurndal) - 2017-04-03 15:47 +0000
                Re: struct padding question supercat@casperkitty.com - 2017-04-03 09:24 -0700
      Re: struct padding question Keith Thompson <kst-u@mib.org> - 2017-04-01 11:43 -0700
      Re: struct padding question Robert Wessel <robertwessel2@yahoo.com> - 2017-04-01 13:46 -0500
        Re: struct padding question Keith Thompson <kst-u@mib.org> - 2017-04-01 12:00 -0700
          Re: struct padding question Robert Wessel <robertwessel2@yahoo.com> - 2017-04-01 16:40 -0500
            Re: struct padding question Keith Thompson <kst-u@mib.org> - 2017-04-01 15:24 -0700
              Re: struct padding question Robert Wessel <robertwessel2@yahoo.com> - 2017-04-03 17:46 -0500
  Re: struct padding question BartC <bc@freeuk.com> - 2017-03-23 11:50 +0000
    Re: struct padding question David Brown <david.brown@hesbynett.no> - 2017-03-23 14:08 +0100
      Re: struct padding question BartC <bc@freeuk.com> - 2017-03-23 13:31 +0000
        Re: struct padding question David Brown <david.brown@hesbynett.no> - 2017-03-23 14:46 +0100
          Re: struct padding question BartC <bc@freeuk.com> - 2017-03-23 14:07 +0000
            Re: struct padding question David Brown <david.brown@hesbynett.no> - 2017-03-23 15:52 +0100
              Re: struct padding question scott@slp53.sl.home (Scott Lurndal) - 2017-03-23 17:19 +0000
                Re: struct padding question David Brown <david.brown@hesbynett.no> - 2017-03-23 19:57 +0100
      Re: struct padding question Ian Pilcher <arequipeno@gmail.com> - 2017-03-23 08:52 -0500
        Re: struct padding question David Brown <david.brown@hesbynett.no> - 2017-03-23 15:54 +0100
          Re: struct padding question supercat@casperkitty.com - 2017-03-23 08:29 -0700
  Re: struct padding question GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-03-23 14:04 +0100
    Re: struct padding question MehdiAmini <atorrses@gmail.com> - 2017-03-23 20:32 +0430
      Re: struct padding question GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-03-23 18:35 +0100
      Re: struct padding question supercat@casperkitty.com - 2017-03-23 12:02 -0700
        Re: struct padding question Keith Thompson <kst-u@mib.org> - 2017-03-23 12:21 -0700
          Re: struct padding question supercat@casperkitty.com - 2017-03-23 12:55 -0700
  Re: struct padding question Les Cargill <lcargill99@comcast.com> - 2017-03-25 15:12 -0500

csiph-web