Discussion of chess software programming and technical issues.
Moderators: hgm , Rebel , chrisw
Rebel
Posts: 6995 Joined: Thu Aug 18, 2011 12:04 pm
Post
by Rebel » Sat Apr 20, 2019 8:50 am
Code: Select all
FILE *fp;
int offset;
fseek(fp,offset,SEEK_SET);
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.
hgm
Posts: 27811 Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller
Post
by hgm » Sat Apr 20, 2019 9:17 am
tmokonen
Posts: 1296 Joined: Sun Mar 12, 2006 6:46 pm
Location: Kelowna
Full name: Tony Mokonen
Post
by tmokonen » Sat Apr 20, 2019 8: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.
konsolas
Posts: 182 Joined: Sun Jun 12, 2016 5:44 pm
Location: London
Full name: Vincent
Post
by konsolas » Sat Apr 20, 2019 8: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)