git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: sizeof(struct ...)

From
René Scharfe <rene.scharfe@lsrfire.ath.cx>
Date
Nov 23, 2006, 15:45 UTC
Message-ID
<4565C205.8050300@lsrfire.ath.cx>
In-Reply-To
<4565A866.8020201@shadowen.org>
Andy Whitcroft schrieb:
Show 12 quoted lines
> This structure represents an on-disk/on-the-wire thing, should we not be
> specifying it in some architecture neutral way?  You are going to get
> the length right in the case of tail padding but not in the face of any
> other padding internally.
> 
> You see packing attributes applied to similar things in the kernel.
> Perhaps they are relevant here?
> Is there not some kind of attribute thing we can apply to this structure
> to prevent the padding?  You see that in the kernel from time to time.
> 
> struct foo {
> } __attribute__((packed));

Yes, that would be nice, but unfortunately __attribute__ is no standard C. Is there really a compiler that inserts padding between arrays of unsigned chars?

Thanks,
Previous: Andy WhitcroftNext: Erik Mouw
Message 5 of 13 in “sizeof(struct ...)”
  1. Gerrit PapeNov 23, 2006
  2. René ScharfeNov 23, 2006
  3. René ScharfeNov 23, 2006
  4. Andy WhitcroftNov 23, 2006
  5. René ScharfeNov 23, 2006
  6. Erik MouwNov 23, 2006
  7. René ScharfeNov 23, 2006
  8. Andy WhitcroftNov 23, 2006
  9. René ScharfeNov 23, 2006
  10. Erik MouwNov 23, 2006
  11. Junio C HamanoNov 23, 2006
  12. archive-zip: don't use sizeof(struct ...)René Scharfe, Nov 23, 2006
  13. Gerrit PapeNov 24, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.