[lug] File size limit issue
Aaron Crane
aaron.crane at pobox.com
Sun Nov 19 14:44:44 MST 2000
"G. Mallén" <mallen at chispa.com.mx> writes:
> The 2 GB limit comes from the fact that C uses a long integer (signed) to
> store the position of the file where you are reading/writing. This is
> obvious in the fseek and fpos man page:
>
> SYNOPSIS
> #include <stdio.h>
>
> int fseek( FILE *stream, long offset, int whence);
> long ftell( FILE *stream);
When compiling, if you
#define _XOPEN_SOURCE 500
before including any system headers, then you get the additional functions
int fseeko(FILE *stream, off_t offset, int whence);
off_t ftello(FILE *stream);
If you also define
#define _LARGEFILE64_SOURCE
then you get
int fseeko64(FILE *stream, off64_t offset, int whence);
off64_t ftello64(FILE *stream);
Alternatively, defining
#define _FILE_OFFSET_BITS 64
makes off_t (as used in fseeko() and ftello() and several other functions) a
64-bit type. Note that all this relates only to libc and compilation
support; you also need a kernel and filesystem that handle large files.
By the way, this sort of thing was discussed here about three weeks ago.
You might find some additional information if you search the archive for
messages with the subject "FW: HELP!".
--
Aaron Crane <aaron.crane at pobox.com> <URL:http://pobox.com/~aaronc/>
More information about the LUG
mailing list