linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nir Dremer <mailing@dremer.org>
To: soraberri <421246@posta.unizar.es>
Cc: linux-c-programming@vger.kernel.org
Subject: Re: newby.-interpreting C
Date: Mon, 20 Dec 2004 21:38:09 +0200	[thread overview]
Message-ID: <1103571489.28578.14.camel@localhost> (raw)
In-Reply-To: <cq77vi$1ej$1@sea.gmane.org>


this specific attributes is intended in order to avoid structure
alignment in memory.
The compiler is performing alignment to any allocation to be a
multiplication of 4k.
in order to disable this alignment __attribute__ packed is being used.

usually this is being used when working with networking:
if you have a structure of 5k and you will send it you will actually
send 8k.

attributes information:
http://www.unixwiz.net/techtips/gnu-c-attributes.html


cheers

On Mon, 2004-12-20 at 20:07 +0100, soraberri wrote:
> Hi all,
> 
> Anyone could give me the meaning of this definition? Is the 
> __attribute__ stuff what scares me. If you feel like I'm too 
> desoriented, please tell me what should I know first.
> 
> typedef struct {
> 	uint8_t b[6];
> } __attribute__((packed)) bdaddr_t;
> 
> thanks very much
> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


  reply	other threads:[~2004-12-20 19:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-20 19:07 newby.-interpreting C soraberri
2004-12-20 19:38 ` Nir Dremer [this message]
2004-12-20 21:17 ` Jan-Benedict Glaw
2004-12-21 15:39   ` soraberri
2004-12-30 11:26   ` Glynn Clements
2004-12-30 11:40     ` Jan-Benedict Glaw

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=1103571489.28578.14.camel@localhost \
    --to=mailing@dremer.org \
    --cc=421246@posta.unizar.es \
    --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).