From: "Daniel." <danielhilst@gmail.com>
To: "linux-c-programming@vger.kernel.org"
<linux-c-programming@vger.kernel.org>
Subject: Does __attribute__((__packed__)) aplies to types or variables?
Date: Wed, 21 Oct 2015 15:56:29 -0200 [thread overview]
Message-ID: <CAF3SDA6FP6=uqs-37_iTH0Qf2hS5Eh5ONVUVcZqEtc3AQ69cfA@mail.gmail.com> (raw)
Suppose that I have a declaration:
struct __attribute__((__packed__)) foo {
char ch;
int number;
};
Will be any variable of this type be packed?
The real world thing is: I have a code that come up from 8bit world,
with a lot of lots of chained structures that are transferred throght
some radio frequence module, I need be sure that all this structs have
no padding so that they can be transferred as they are to radio. To
achieve this I've
putted __attribute__((__packed__)) to every struct and inner struct
that are sended through RF,
but I read at some StackOverflow post that packed attribute aplies to
variables not to types,
so I came here ask to experts. Is that true?
At gcc manual I found Type Attributes and Variable attributes, so I'm
assuming both exists how differentiate from one to another?
Regards,
--
"Do or do not. There is no try"
Yoda Master
next reply other threads:[~2015-10-21 17:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-21 17:56 Daniel. [this message]
[not found] ` <CAK7N6vrh05XDwa_nBTmid8QZUU8wgFhm0w=R+aMA9tOugL46Mg@mail.gmail.com>
[not found] ` <CAF3SDA7pObzwzk-AzdO38-c45VggTJJpwdNzujAuyMV=eSCc=w@mail.gmail.com>
2015-10-22 16:18 ` Does __attribute__((__packed__)) aplies to types or variables? Daniel.
2015-10-24 0:52 ` Phil Sutter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAF3SDA6FP6=uqs-37_iTH0Qf2hS5Eh5ONVUVcZqEtc3AQ69cfA@mail.gmail.com' \
--to=danielhilst@gmail.com \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).