k t
k t

Reputation: 363

Handling big files on 32bit machine with gcc

How do i handle big files (>10 GB) with c (at least reading them)? I don't have a 64bit machine, so the compiler Option
-D_FILE_OFFSET_BITS=64 won't work.

Upvotes: 1

Views: 593

Answers (1)

Joshua D. Boyd
Joshua D. Boyd

Reputation: 4856

This looks likely to be a duplicate of Reading a large file using C (greater than 4GB) using read function, causing problems

Since you mention GCC, I'm assuming Linux, Solaris, or something similar. If you are using GCC on Windows, I don't know if the following will hold true.

If you just open the file with O_LARGEFILE and use read, it should work, provided that you don't try to keep the entire file in memory and that your read size is under 32 bits in size. Same for write. If you need to seek, use lseek64 and compile with #define _LARGEFILE64_SOURCE (note, lseek64 is not entirely standard, so if you aren't on Linux, the lseek man page will hopefully point you to the prefered solution).

Upvotes: 1

Related Questions