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


Groups > comp.lang.c > #106809

Re: struct padding question

Path csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: struct padding question
Date Thu, 23 Mar 2017 08:45:33 -0700
Organization None to speak of
Lines 31
Message-ID <lnwpbg9eua.fsf@kst-u.example.com> (permalink)
References <ob062g$coi$1@dont-email.me> <ob07qd$if0$1@dont-email.me> <ob0e1p$b4l$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Injection-Info mx02.eternal-september.org; posting-host="1b33b319c9f9fcfff45ec1f5b5f6ee2d"; logging-data="20809"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18tVmCf8rd/tqj2sZ5BwO+J"
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)
Cancel-Lock sha1:ply9s9t6CVmrn+RnugJMvCYF6aM= sha1:oRLxs0NtGyA0ye8rROPeNJUvr3c=
Xref csiph.com comp.lang.c:106809

Show key headers only | View raw


MehdiAmini <atorrses@gmail.com> writes:
> On 03/23/2017 02:58 PM, David Brown wrote:
>> On 23/03/17 10:58, MehdiAmini wrote:
> [...]
>
>> You may decide that this warning is not a problem - for most code,
>> padding bytes are not an issue.  Then you simply add "-Wno-padded" to
>> your compiler line.  This does not change your code, but it hides the
>> warning.
>>
>> Alternatively, you need to re-arrange your struct so that there are no
>> paddings needed.
>>
>
> [...]
>
> Can I use alignas or alignof to fix the warning?

Exactly what problem are you trying to solve?

The simplest way to avoid the warning is to add "-Wno-padded" to
your compiler command line.  If you want the structure not to have
padding, that's a more complicated question.  In some cases you can
rearrange the member declarations, but in this case you could add
a dummy member to occupy the space that would otherwise be padding.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
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"

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