[GRASS-dev] fseeko() in libiostream
Andrew Danner
adanner at cs.swarthmore.edu
Mon Oct 6 18:51:00 EDT 2008
Paul Kelly wrote:
> In some recent enhancements to the iostream library,
> include/iostream/ami_stream.h had a call to fseek() changed to fseeko().
> This now doesn't compile on Windows; a sample error is:
>
> sh-2.04$ make
> make OBJ.i686-pc-mingw32
> make[1]: Entering directory `/c/grass/grass7/lib/iostream'
> make[1]: `OBJ.i686-pc-mingw32' is up to date.
> make[1]: Leaving directory `/c/grass/grass7/lib/iostream'
> c++ -I/c/grass/grass7/dist.i686-pc-mingw32/include
> -I/c/grass/extra/include -O2 -s -I/c/grass/extra/include
> -D_FILE_OFFSET_BITS=64 -DPACKAGE=\""grasslibs"\"
> -I/c/grass/grass7/dist.i686-pc-mingw32/include -o
> OBJ.i686-pc-mingw32/ami_stream.o -c ami_stream.cc
> In file included from ami_stream.cc:47:
> c:/grass/grass7/dist.i686-pc-mingw32/include/grass/iostream/ami_stream.h:
> In member function `AMI_err AMI_STREAM<T>::seek(off_t)':
> c:/grass/grass7/dist.i686-pc-mingw32/include/grass/iostream/ami_stream.h:432:
> error: there are no arguments to `fseeko' that depend on a template
> parameter, so a declaration of `fseeko' must be available
> c:/grass/grass7/dist.i686-pc-mingw32/include/grass/iostream/ami_stream.h:432:
> error: (if you use `-fpermissive', G++ will accept your code, but
> allowing the use of an undeclared name is deprecated)
> make: *** [OBJ.i686-pc-mingw32/ami_stream.o] Error 1
> sh-2.04$
>
> Am I right in thinking that if large file support is configured properly
> there should be no need to use fseeko() to seek in large files, and
> fseek() should be fine? I looked in r.in.xyz which only uses fseek() and
> ISTR discussion about it handling huge files recently, although perhaps
> that involved reading from stdin.
>
> Paul
>
fseek is not the same as fseeko.
int fseek(FILE *stream, long offset, int whence);
int fseeko(FILE *stream, off_t offset, int whence);
If large file support is enabled, fseeko will convert off_t to a 64 bit
type even on a 32-bit OS. I'm not sure if long will be 64 bit on a
64-bit OS for fseek.
r.in.xyz may work with large files using plain old fseek as long as
r.in.xyz doesn't make long seeks. ami_stream.h could potentially make
long seeks (e.g., skip the first 8GB of a 30GB file), though in
practice, I'm not sure that code that uses ami_stream (r.terraflow)
actually uses this kind of fseek. Still the interface is designed to
potentially use long seeks and I would be reluctant to simply replace
fseeko with fseek in ami_stream.h.
you may to add a #define to check the compiler type and use fseek only
if fseeko does not exist.
-Andy
More information about the grass-dev
mailing list