Was |int| always thought to be 32bit ?
Lars Knoll
lars at trolltech.com
Tue Apr 26 00:16:47 PDT 2005
On Tuesday 26 April 2005 08:40, Mike A. Harris wrote:
> Roland Mainz wrote:
> > Egbert Eich wrote:
> >> > While looking at the X11 headers I see that some structure members and
> >> > function arguments and return values use |int| - was that datatype
> >> > thought to be always 32bit or is there any platform which used 16bit
> >> > for
> >> >
> >> > |int| to work with X11 code (client side+Xserver), too (parts of the
> >> >
> >> > code use |short| to explicitly say "... it's 16bit..." but I cannot
> >> > find a clear statement was |int| should be...) ?
> >>
> >>Appearantly at one time there used to be X implementations for DOS
> >>where int was 16bit unless you used a DOS extender and ran in protected
> >>mode. I'm not sure if any Xserver implementation was real mode, though.
> >>The use of short as 'it's 16bit' is rather poor. Fixed sizes should
> >>be taken form system headers where avaialble or defined in an X header.
> >
> > AFAIK all C implementations take |short| as 16bit. Originally (before
> > 64bit machines were "invented") |long| was 32bit and |int| was a
> > datatype which picked the "natural" representation of an integer for
> > this machine type (or better: the representation which was the fastest
> > or "best" for register/memory access) ...
>
> "all" is pushing it a bit. "All C implementations that we support
> and care about" might be more realistic. I don't think we should
> assume that the standard integer types have a specific bitwidth
> however unless using the stdint.h typedefs, or using our own
> wrappers.
Not sure if this helps you, but here's our experience with Qt on our supported
platforms:
short is 16bit and int is 32 bit on all of them.
sizeof(long) == sizeof(void *) for all platforms but 64bit Windows (where long
is 32bit).
I very much doubt you will be able to find a C compiler nowadays that is
interesting as a target for X11, that has different sizes for short and int.
That being said, it probably makes a lot of sense to use typedefs that
guarantee a specific width in code that relies on this.
Cheers,
Lars
More information about the xorg-arch
mailing list