Re: larger than 32 bit ints and OS's

From: Daniel Koepke (dkoepke@CALIFORNIA.COM)
Date: 09/25/97

On Thu, 25 Sep 1997, Rob Baumstark wrote:

-+There is probably a similar thing in linux, and all those other operating
-+systems you people use.  If your using Windows though with the MSVC++
-+compiler there is a 64bit integer variable..., __int64.  It might be a good
-+addition to Circle BPL12 to have the Win version use them instead.  Fer you
-+windows people..., a few data types you might not be aware of...

It'd be a *terrible* idea to use int<size> type of variables.
Simply because: (a) not all compilers do it in the same way,
(b) not all variables are the same size on all computers which
makes it horribly unbalanced.

MSVC++ has __int64.  gcc has "long long" 64-bit integers.  There
is not why to actually have the code automatically know integer
sizes and how to typedef "int8/int16/int32/int64" save for doing
so in the configuration script.

In other words, we'd need to know how each platform decides
what is an 8-bit, 16-bit, 32-bit, or 64-bit integer, and that's
not just compiler based, but computer based, and operating
system based.  If we could have access to all of that information,
(we actually do under most UNIX operating systems, although it's
typically different on how or if we can access it) then we could
keep Circle portable.

-+__int8          I think the 8 bit int exists..., same as a byte, or char
-+__int16         On linux, should be the same as an int, a short int on windows
-+__int32         A long int in linux, an int in windows
-+__int64         Like above, a 64bit int

You've obviously not used Linux before, or at least not
extensively.  To put it one way: Linux is a 32-bit operating
system, and was before Windows 95 came about.  Windows 3.1
has 16 bit integers and 32 bit long integers.  Win95 pretty
much took a page from the book of Linux having 32-bit integers
(and long integers), and 16-bit short integers.  In other

__int16         A short integer on Linux and Windows95
__int32         An integer or long integer on Linux and Windows95
__int64         Type in MSVC++, a "long long" under gcc

-+Remember that changing all your bitvectors to __int64's will corrupt the
-+playerfile, rentfiles, and any other binary files.

And make your MUD incompatible with other operating systems.  If
you're going to make it use 64-bit integers, then use a typedef
in structs.h or conf.h or sysdep.h to do it.  Something like:

  typedef long long     int64; // change for portability

Daniel Koepke -:- -:-  [Shadowlord/Nether]

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | |

This archive was generated by hypermail 2b30 : 12/08/00 PST