www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/04/29/04:18:08

Date: Mon, 29 Apr 1996 00:28:31 +0800 (GMT+0800)
From: Orlando Andico <orly AT abigail DOT eee DOT upd DOT edu DOT ph>
To: Nicholas Lynch <br516 AT FreeNet DOT Carleton DOT CA>
cc: djgpp AT delorie DOT com
Subject: Re: sizeof(int) == 4?!
In-Reply-To: <4m03nd$nsc@freenet-news.carleton.ca>
Message-ID: <Pine.LNX.3.91.960429002714.305A-100000@abigail.eee.upd.edu.ph>
MIME-Version: 1.0

That's because that's how it's down in Unix. It is not true that an "int" 
is always 16-bits long. ANSI C specifies that a long is AT LEAST the size 
of an int, not necessarily longer.

To use a 2-byte int, use "short int"


On 28 Apr 1996, Nicholas Lynch wrote:

>  I was having some trouble using a structure to load a file header in DJGPP.
> I found that it worked in borland C no problem. So, I wrote a little test
> program that would give me the sizes of several data types:
> 
> Borland C/C++:
> 
>   Variable         Size
>   ---------------------
>   int              2
>   unsigned int     2
>   long             4
>   ...
> 
> But in DJGPP:
> 
>   Variable         Size
>   ---------------------
>   int              4
>   unsigned int     4
>   long             4
>   ...
> 
>  Is there any way of correcting this? (I belive that this problem cropped up
> earlier in thee newsgroup, but I didn't save the solution :( Or, should I
> just use a different data type instead of int?
> 
>  Thanks in advance...
> --
>    O                   Nicholas Lynch
>   -|-                 br516 AT freenet DOT carleton DOT ca
>   / \
> 

- Raw text -


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