[MLton] Port to HP-UX
Mon, 24 Apr 2006 18:52:39 +0300
Quoting Ville Laurikari <firstname.lastname@example.org>:
> Anyway, I'm getting warnings like this with gcc:
> gc.c: In function 'GC_display':
> gc.c:343: warning: format '%u' expects type 'unsigned int', but argument 9 has type 'long int'
> gc.c:343: warning: format '%d' expects type 'int', but argument 10 has type 'long int'
> gc.c:349: warning: format '%u' expects type 'unsigned int', but argument 4 has type 'long int'
> gc.c:349: warning: format '%u' expects type 'unsigned int', but argument 5 has type 'long int'
> It seems that on this platform, pointer arithmetic gives a result of
> type 'long int' rather than 'int'.
Here are two relevant quotes from a C99 standard draft. The result
of subtracting two pointers is a 'ptrdiff_t':
[#9] When two pointers are subtracted, both shall point to
elements of the same array object, or one past the last
element of the array object; the result is the difference of
the subscripts of the two array elements. The size of the
result is implementation-defined, and its type (a signed
integer type) is ptrdiff_t defined in the <stddef.h> header.
To format a 'ptrdiff_t' value, the 't' length modifier should be used:
[#7] The length modifiers and their meanings are:
t Specifies that a following d, i, o, u, x, or X
conversion specifier applies to a ptrdiff_t or
the corresponding unsigned integer type
argument; or that a following n conversion
specifier applies to a pointer to a ptrdiff_t