[GRASS-dev] fseeko() in libiostream

Glynn Clements glynn at gclements.plus.com
Wed Oct 8 02:23:06 EDT 2008


Paul Kelly wrote:

> >> +#ifdef HAVE_LARGEFILES
> >> +       filesize = ftello(in_fp);
> >> +#else
> >>          filesize = ftell(in_fp);
> >> +#endif
> >
> > Can we add library functions, G_fseek() and G_ftell(), which use an
> > off_t. The functions would use fseeko/ftello if available, fseek/ftell
> > otherwise, but would always accept and return off_t.
> 
> But isn't off_t not always the same size - IIUC it depends on whether 
> _FILE_OFFSET_BITS is defined and what it is set to? Should there be a 
> typedef FILE_OFFSET which is equivalent to the "correct" off_t, or 
> something similar?

Right. In order for this to work, we would need to enable LFS
unconditionally, so that there's no chance of module code getting a
different off_t to libgis.

Actually, we would need to do it via CFLAGS. Relying upon config.h is
unsafe, as stdio.h typically gets included before config.h.

OTOH, enabling LFS unconditionally all but requires the above
functions, as plain fseek/ftell are incompatible with LFS, and
fseeko/ftello aren't guaranteed to be available.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list