In iomonad.c of the February 2000 Hugs release, primHGetPosn and
PrimHSetPosn attempt to coerce fpos_t to an integer. This code is
incorrect, because whether or not fpos_t is an integral type or a
structured type is up to the C library implementation.
The ANSI C specification states that fpos_t is "an object type other
than an array type capable of recording all the information needed to
specify uniquely every position within a file". In fact, it is clear
from the definitions of fgetpos and fsetpos that in the C99 specification,
fpos_t cannot (easily) be an integral type.
Although glibc 2.1 and other pre-C99 C libraries may allow fpos_t to be
coerced into an int, glibc 2.2's C99 support requires that additional
information be stored in fpos_t (mbstate_t, used for multibyte-character
support), breaking code that relied on this implementation detail.
It seems that the correct approach is to use ftell, which, despite the
comment in the Hugs source that an approach using ftell is merely ``A
reasonable approximation for pre-ANSI compilers'', is both valid ANSI
C and the correct way to get file positions as an integer.
M.E.O.