Operating System - HP-UX
1755016 Members
2633 Online
108828 Solutions
New Discussion юеВ

Large file support on hp-gcc-4.4.3

 
SOLVED
Go to solution
Carlos A Jimenez
New Member

Large file support on hp-gcc-4.4.3

Hi,

I'm have a program that runs on a HP server 11.11. This program reads and writes files, but i haven't noticed that it cannot open large files (>2Gb). I have tried flags -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 but it doesn't work.

Here is how i open the files:

#include
#include

using namespace std;

int main(int argc, char* argv[])
{
fstream file;

if (argc < 2) {
cout << "Usage: " << argv[0] << " filename" << std::endl;
exit(1);
}

file.open(argv[1], ios::in);
if (!file)
{
cout << "Input file " << argv[1] << " not found.\n";
exit(1);
} else {
cout << "Input file " << argv[1] << " opened.\n";
}


return 0;
}

Any idea how to use fstream to open >2gb files?

Thanks
Carlos
3 REPLIES 3
Dennis Handly
Acclaimed Contributor
Solution

Re: Large file support on hp-gcc-4.4.3

>Any idea how to use fstream to open > 2gb files?

If you want large file support you should use stdio or direct system calls and not C++.
aC++ does NOT support large files and I assume g++ probably has the same limitation?
Carlos A Jimenez
New Member

Re: Large file support on hp-gcc-4.4.3

Thanks, but it's really bad for me as i need to change a lot of thing in the code to accommodate this.
Dennis Handly
Acclaimed Contributor

Re: Large file support on hp-gcc-4.4.3

>it's really bad for me as I need to change a lot of thing in the code

I suppose you could download the g++ runtime source and implement large files. It wouldn't be binary compatible.