cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1999/06/14/05:29:09

Message-ID: <CD4DE0181670D211AC5400A0C94BD1B81206E5@dksmsx30.idk.intel.com>
From: "Alstrup, Kurt" <kurt DOT alstrup AT intel DOT com>
To: "'djgpp AT delorie DOT com'" <djgpp AT delorie DOT com>
Subject: RE: How does fwrite align ?
Date: Mon, 14 Jun 1999 02:28:35 -0700
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2448.0)
Reply-To: djgpp AT delorie DOT com

Sunil,

  I don't think it is fwrite who is reponsible for this 'alignment'.
It is the sizof() operator, which returns a struct size longer than what you
expect. The size of a struct (unless non-standard options like '#pragma
packed' is used) is adjusted so that structs in an array will be properly
aligned. In practise the largest simple element in your struct sets the
alignment.
Hope this helps.

Regards,
Kurt Alstrup

-----Original Message-----
From: Sunil V [mailto:sunilv AT accord-soft DOT com]
Sent: Monday, June 14, 1999 11:19 AM
To: djgpp AT delorie DOT com
Subject: How does fwrite align ?


Hello everybody,
I have observed that when I use something like fwrite(&XXX,
sizeof(struct X),  1, file_pointer);
in  a loop, the next record is not written immediately after the first
record. The next record is aligned to an int boundary ( that is what I
observed on my m/c, where in the size of int is 4 bytes). Is there a
hard and fast rule that dictates the way alignment has to be performed
or is it dependent on the compiler or the architecture of the machine ?

Please reply ASAP
Regards Sunil



--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019