Re: TIP #129 and 64 Bit platforms

From: Benjamin Riefenstahl (Benjamin.Riefenstahl_at_epost.de)
Date: 12/08/03


Date: Mon, 08 Dec 2003 18:46:36 +0100

Hi Matthias,

Matthias.Rohr@SturmIT.de (Matthias Rohr) writes:
> What I need are integer types, that are the same size on all
> platforms, something like Tcl_Int2, Tcl_Int4. Tcl_Int8.

Why? I use int or short as "at-least-16-bits", long as
"at-least-32-bits" and long long (or a typedef if I have to support
VC) for "at-least-64-bits". I never use built-in types as overlays
for byte arrays, so I never need exact-sized types. Instead I use
unsigned version of all types and bit shift, binary "and" and binary
"or" to convert from byte array to number and back. Keeps my code
portable with ease and without unnecessary #ifdefs.

benny



Relevant Pages

  • Re: byte order
    ... casting objects to arrays of bytes, and guarantees that such an array ... The standard also gives the possibility of integer types containing ... padding bits, and it is not specified how such bits can be detected. ... code that cares about endianness, so it's not really an issue. ...
    (comp.lang.lisp)
  • Re: [C] functions and 2D arrays?
    ... >>This works, and I like the idea of using typedef, but to solidify ... 'int ' for every instance of 'foo bar' in the code. ... to arrays of arrays of int, when you could be passing pointers ...
    (alt.comp.lang.learn.c-cpp)
  • Re: size of a typedef with arrays of unsigned char
    ... arrays of unsigned char, the sum of the size of the arrays? ... The reference to typedef is irrelevant. ... in a record consisting of arbitrary byte-sized chunks, ...
    (comp.lang.c)
  • Re: byte order
    ... casting objects to arrays of bytes, and guarantees that such an array ... The standard also gives the possibility of integer types containing ... padding bits, and it is not specified how such bits can be detected. ... Bound variables, free programmers. ...
    (comp.lang.lisp)
  • Re: Returning structs containing arrays
    ... > of ints and an int. ... contains two pointers and an integer. ... arrays if you initialize them to point to allocated memory. ... The typedef "arrays" doesn't name a structure type; ...
    (comp.lang.c)