All 64-bit applications can manipulate large files by default. The methods described on this page allow 32-bit applications to manipulate large files.
In the large file compilation environment, source interfaces are bound to appropriate 64-bit functions, structures, and types. Compiling in this environment allows 32-bit applications to access files whose size is greater than or equal to 2 gigabytes (2**31 bytes).
Each interface named xxx() that needs to access 64-bit entities to access large files maps to a xxx64() call in the resulting binary. All relevant data types are defined to be of correct size (for example, off_t has a typedef definition for a 64-bit entity).
An application compiled in this environment is able to use the xxx() source interfaces to access both large and small files, rather than having to explicitly utilize the transitional xxx64() interface calls to access large files. See the lfcompile64 page for information regarding the transitional compilation environment.
Applications can be compiled in the large file compilation environment by using the following methods:
Set the compile-time flag _LARGEFILE64_SOURCE to 1 before including any headers.
Set the compile-time flag _FILE_OFFSET_BITS to 64 before including any headers. Applications may combine objects produced in the large file compilation environment with objects produced in the transitional compilation environment, but must be careful with respect to interoperability between those objects. Applications should not declare global variables of types whose sizes change between compilation environments.
Applications wishing to access
In the following examples, the large file compilation
environment is accessed by invoking the getconf utility
with one of the arguments listed in the table above. The
additional large file interfaces are accessed by specifying
The examples that use the form of command substitution specifying the command within parentheses preceded by a dollar sign can be executed only in a POSIX-conforming shell such as the MKS KornShell (see sh). In a shell that is not POSIX-conforming, such as sh in Bourne-Again Shell mode (see sh) or the C Shell (see csh), the getconf calls must be enclosed within grave accent marks, as shown in the second example.
$ cc -D_LARGEFILE_SOURCE \ -D_FILE_OFFSET_BITS=64 -o foo \ -D_LARGEFILE64_SOURCE y.tab.c b.o \ $(getconf LFS_LDFLAGS) -ly
% c89 -D_FILE_OFFSET_BITS=64 \ -D_LARGEFILE64_SOURCE a.c \
$ c89 -D_LARGEFILE_SOURCE a.c
In general, caution should be exercised when using any separately-compiled library whose interfaces include data items of type off_t or the other redefined types either directly or indirectly, such as with struct stat. (The redefined types are off_t, rlim_t, ino_t, blkcnt_t, fsblkcnt_t, and fsfilcnt_t.) For the large file compilation environment to work correctly with such a library, the library interfaces must include the appropriate xxx64() binary entry points and must have them mapped to the corresponding primary functions when _FILE_OFFSET_BITS is set to 64.
Care should be exercised using any of the
Large File Specification, revision 1.5.
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
PTC MKS Toolkit 10.3 Documentation Build 39.