fseek problem files >2Gb (32-bit compile)

Discussion of chess software programming and technical issues.

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Post Reply
User avatar
Posts: 5250
Joined: Thu Aug 18, 2011 10:04 am

fseek problem files >2Gb (32-bit compile)

Post by Rebel » Sat Apr 20, 2019 6:50 am

Code: Select all

FILE *fp;
int offset;
When the file is >2Gb it crashes.

Changing int offset; to:

Code: Select all

unsigned int offset;
unsigned long long offset; (64 bit in my compiler)
Doesn't help, same crash.

Is there a way out?
90% of coding is debugging, the other 10% is writing bugs.

User avatar
Posts: 24565
Joined: Fri Mar 10, 2006 9:06 am
Location: Amsterdam
Full name: H G Muller

Re: fseek problem files >2Gb (32-bit compile)

Post by hgm » Sat Apr 20, 2019 7:17 am

Posts: 1112
Joined: Sun Mar 12, 2006 5:46 pm
Location: Vancouver

Re: fseek problem files >2Gb (32-bit compile)

Post by tmokonen » Sat Apr 20, 2019 6:24 pm

Just be aware that _fseeki64 and _ftelli64 are Windows specific. I used the the more portable POSIX functions fseeko64 and ftello64 with GCC under windows successfully, although I am not sure they will work with Microsoft's compiler.

Posts: 182
Joined: Sun Jun 12, 2016 3:44 pm
Location: London
Full name: Vincent

Re: fseek problem files >2Gb (32-bit compile)

Post by konsolas » Sat Apr 20, 2019 6:34 pm

If you're on windows, you could also switch to c++ (std::ifstream supports all this natively) or use the windows API directly (CreateFile)

Post Reply