[M3devel] long vs. INTEGER? ranges vs. word/integer?
Jay
jay.krell at cornell.edu
Sat Jan 3 00:05:24 CET 2009
I'd like to avoid using "long" and "ulong" anywhere.
On Unix, they are always pointer sized.
On Windows, they are always 32 bits.
This divergence of meaning I think it renders it useless.
I believe for pointer-sized integers, the right types are any of:
unsigned: size_t, Word.T
signed: INTEGER, ssize_t, ptrdiff_t
For 32bit integers: int32_t and uint32_t, perhaps int.
There is arguably some ambiguity if you consider 16bit platforms.
Now, I noticed we have:
INTERFACE Cstddef;
size_t = Ctypes.unsigned_long; ssize_t = Ctypes.long; ptrdiff_t = Ctypes.long;
I would like to change this, either to:
32bits:
size_t = Ctypes.unsigned_int; ssize_t = Ctypes.int; ptrdiff_t = Ctypes.int;
64bits:
size_t = Ctypes.unsigned_long_long; ssize_t = Ctypes.long_long; ptrdiff_t = Ctypes.long_long;
or portable:
size_t = Word.T; ssize_t = INTEGER; ptrdiff_t = INTEGER;
but, my question then is, why isn't the portable version already in use?
Especially for the signed types.
I mean, you know, we have:
32bits/BasicCtypes:
INTERFACE BasicCtypes;
IMPORT Word, Long;
TYPE (* the four signed integer types *) signed_char = [-16_7f-1 .. 16_7f]; short_int = [-16_7fff-1 .. 16_7fff]; int = [-16_7fffffff-1 .. 16_7fffffff]; long_int = [-16_7fffffff-1 .. 16_7fffffff];
question is, why aren't int and long_int INTEGER?
64bits/BasicCtypes:
long_int = [-16_7fffffffffffffff -1 .. 16_7fffffffffffffff ]; long_long = [-16_7fffffffffffffffL-1L .. 16_7fffffffffffffffL];
why not INTEGER?
- Jay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20090102/f12b09dc/attachment-0001.html>
More information about the M3devel
mailing list