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

When Created: 11/21/1997 07:47:35
Against DJGPP version: 2.01
By whom: stephen.bint@virgin.net
Abstract: sizeof(unsigned) returns 4, not 2
The sizeof operator returns 4, for an unsigned.

#include <stdio.h>
main() {
printf( "sizeof(unsigned) = %u\n", sizeof(unsigned) );
}

output:

sizeof(unsigned) = 4

Solution added: 11/21/1997 18:40:27
By whom: eggbrains@aol.com
it isn't a bug

in p-mode the defualt integer size is long (4 bytes) instead of 
real modes default short (2) bytes.

sizeof(unsigned short) = 2
sizeof(unsigned long) = 4

//default varible is 4 bytes 
sizeof(unsigned) = sizeof(unsigned long)

Note added: 12/16/1997 07:22:25
By whom: gngking@erols.com
It's not protected-mode which does that!  DJGPP makes 32-bit programs.
Therefore, integers are four bytes long.  (Protected-mode on the 286
micro-processor is 16 bits.  So, "int"s are the same as "short int"s, there.)

Closed on 04/12/1999 10:00:03: This is not a bug, but an expected behavior of GCC.
By whom: eliz@is.elta.co.il



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