delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/11/16:19:25

From: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Why does sizeof give me...
Date: 8 Aug 1997 05:57:10 GMT
Organization: The National Capital FreeNet
Lines: 30
Message-ID: <5secfm$hjq@freenet-news.carleton.ca>
References: <199708070420 DOT OAA16036 AT rabble DOT uow DOT edu DOT au>
Reply-To: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire)
NNTP-Posting-Host: freenet6.carleton.ca
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Brett Leslie Porter (bporter AT rabble DOT uow DOT edu DOT au) writes:
>> Hello, hello!
> Hello, Hello, Hello!
>> 
>> I'm converting some code from my old 16 bit c programs to
>> 32 bit .. suddenly sizeof gives me values that are many bytes
>> larger than my old structures! This means whenever i want to fread 
>> and fwrite files the structures get's messed up! 
>> 
> Yes, 32-bit OS pads out structures, I think to dword boundary. Someone else
> can probably help you more here, as I'm am not entirely certain how it
> works, as I am not converting any 16 to 32 bit programs (yet!) You can
> probably set a compiler switch to turn off alignment, I'm not sure.

I was able to get a C++ program from DJGPP to read binary files that were
made by a Visual Basic app (16 bit) using struct packing and using shorts
to read what VB calls ints. (VB won't emit zero terminated strings which
is a pain... its normal string format is two bytes describing length then
the string, and the fixed length string is stored as just the string, no
delimiter null, and padded with spaces. The C program has to chop off
terminating white space and append a null, or read the length and string
and append a null... a chore...)


--
    .*.  Where feelings are concerned, answers are rarely simple [GeneDeWeese]
 -()  <  When I go to the theater, I always go straight to the "bag and mix"
    `*'  bulk candy section...because variety is the spice of life... [me]
Paul Derbyshire ao950 AT freenet DOT carleton DOT ca, http://chat.carleton.ca/~pderbysh

- Raw text -


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