I am currently running ROOT Version 4.01 on an i686 machine with Red Hat Release 9.
I would like to read an ASCII file containing what is basically an N-tuple. The file is approx. 7 GB and the exact same code works perfectly on a similar input file of approx. 1 GB. However, it does not work with the large file, and “fopen” returns a NULL.
I have read the few previous posts regarding the use of “fopen” with large files, but cannot implement these suggestions, and most include the use of a #define _LARGEFILE_SOURCE statement with the #include<stdio.h>.
Is this solution supposed to be compatible with ROOT’s CINT??
and then to use fopen() as usual (since with this implementation, fopen becomes fopen64 automatically).
The problem was with the platform or the libraries on the machine I was running the analysis originally…changing systems solved the problem, although I still do not know why
#define _LARGEFILE_SOURCE
#define _LARGEFILE64_SOURCE
should be used, in my opinion, only as a short term expedient.
The major problem is that now fopen but more importanly pos_t means something for your compilation unit and something totally different from another compilation unit. So it works if and only if the functions (related to the FILE) that you are calling all comes from stdio.h.
Thanks Phillipe. I had read something about the limited ability of this way around my problem in the documentation for it. Since I do only use fopen, and in fact only use it once, it works just fine for me.
Can you suggest a more general solution to the problem?
I have however, tried to use ‘fopen64’ as suggested by both Rene and Phillipe. The problem is that I get the error message
Error: Function fopen64(logfile,"r") is not defined in current scope FILE:EventTree64_4.C LINE:77
Can someone point me to how to fix this problem? Just to be clear, I use ROOT Version 4.03/04 on a dual-boot Linux OS running SLC3 and with the current GCC 3.2.3-52 that comes with it.