www.delorie.com/djgpp/bugs/show.cgi   search  
Bug 000296

When Created: 07/31/1999 14:00:32
Against DJGPP version: 2.02
By whom: MDK187@DeathsDoor.com
Abstract: int size problem
When I write c++ code like this,

   cout << sizeof(int) << sizeof(long);

it reports that both integers and long int's take up 4 bytes.  I am new to DJGPP, and I am wondering if it is suppose to be like this.  It would be pointless if it were, since it would be the exact same type and you couldn't use a 16-bit int to automatically wrap it on overflow modulo 0xFF.

MDK187

Solution added: 08/03/1999 06:00:38
By whom: bazramit@yahoo.com
Is this really a bug? in protected mode 32 bit environment, an integer is 32 bits! (integer length depends on the machine)
long ints are always 4 bytes! 
so... where is the problem? :)

Note added: 08/03/1999 10:00:08
By whom: broeker@physik.rwth-aachen.de
This is not, nor has it ever been a 'bug' or even a 'problem'.
Who said that 'int' and 'long int' should not be of equal
size (and, thus, range)? 

Hint: if you want 16bit integers, use 'short int'.

For a cleanly written, portable program, none of these issues should
ever make a difference. 

I'm closing this issue.

Closed on 08/03/1999 10:00:09: Not a bug: misunderstanding of programming language
By whom: broeker@physik.rwth-aachen.de



  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2010   by DJ Delorie     Updated Jul 2010