[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [Devel] FT_PtrDist is badly defined and should be abolished
From: |
Turner, David |
Subject: |
RE: [Devel] FT_PtrDist is badly defined and should be abolished |
Date: |
Wed, 13 Oct 2004 13:24:54 +0200 |
Hi,
> There are two points I'd like to make here. First, surely it
> *will* work on these systems, because 'long' would be 64 bits?
I believe that this is not necessary in all cases of 64-bits systems,
and this is mainly due to compatibility. Have a look at the description
of the LLP64 memory model, at the following pages for an example:
http://en.wikipedia.org/wiki/64-bit
Basically, 'long' is still 32-bits, and 'long long' is the largest
integer that matches pointers.
> For this to work, all we need is for 'long' to encompass the entire address
> range.
> Secondly, when I said "It is inconceivable that this code would ever have to
> handle pointer distances unrepresentable by a 'long' " I was thinking not of
> the full
> address range of the system, but of the size of Type 1 font files; I refuse
> to believe in a font file of any type as long as 2^32 bytes.
>
> <<<<<<
> I don't agree that FT_PtrDist should be abolished, it can be used to*
> get rid of some compiler warnings in certain cases.
> >>>>>>
>
> How? Pointer arithmetic is guaranteed to return a signed integral type. If
> we use the largest signed integral type, 'long', to hold such numbers, we
> cannot go wrong. If we then try to store such a number somewhere in a smaller
> integral type (and I can't see a good reason for doing that) we will
> get a warning; this can easily be overcome by a cast. Is that what you
> meant?
>
Well, if 'long' is not the largest integral type, this doesn't work.
And of course, there is the case where 'long' is larger than a pointer
(e.g. in DSPs I believe), so using them can be less efficient than
size_t, ssize_t and ptrdiff_t (but we're really not at that level of
sophistication :-))
Regards,
- David Turner
- The FreeType Project (www.freetype.org)
> In the end it's a matter of style, and ease of reading code. I like to
> reduce the number of these typedefs, and abolish those of limited
> application and dubious value. Still, FreeType is consistent,
> which cannot
> be said of GhostScript, which has a bewildering number of different
> typedef'ed and #define'd boolean types: I found bool, BOOL, GSBOOL,
> gboolean, and Boolean, and there are probably more.
>
> Best wishes,
>
> Graham Asher
>
> P.S. a downloadable demo of my latest project, CartoType (a
> cartography library), which uses FreeType, is now available at
> www.cartotype.com. My hearfelt thanks once more to you and all other
> FreeTypers. FreeType runs equally well in CartoType on three platforms
> so far: Windows, Symbian OS and Palm OS.
>