When I run the following program (did not write it) on a 32 bit machine it will not compile and run correctly. However if I compile and run it on my 64 bit machine it works fine. Would appreciate any ideas on this, do you think this is a bug or is there a problem with the compiler or the program? Thanks for any help you can give!! Charley Program #include <fstream> #include <iostream> #include <iomanip> using namespace std; int main() { unsigned long long kb = 1024; unsigned long long mb = kb * kb; unsigned long long gb = kb * mb; unsigned long long four_gb = gb * 4; long long ten_gb = gb * 10; int write_count = four_gb / kb; cout << "kb: " << kb << "\nmb: " << mb << "\ngb: " << gb << "\nfour_gb: " << four_gb << "\nten_gb: " << ten_gb << endl; unsigned char* buf = new unsigned char[kb]; memset(buf, 0, kb); double total_writes = write_count; double writes = 0; ofstream os("big_file"); cout << setiosflags(ios::fixed) << setprecision(0); for (int i = 0; i < write_count; ++i) { os.write((char*)buf, kb); ++writes; cout << "\r" << setw(3) << (writes / total_writes * 100.0) << "%" << flush; } os.close(); cout << "\r100%\nFinished..." << endl; // Open for reading and test seek. ifstream is("big_file"); std::streampos pos = four_gb-1000; // Arbitary position. is.seekg(pos); std::streampos new_pos = is.tellg(); if (pos == new_pos) { cout << "Seek to " << pos << " worked!" << endl; } else { cout << "Seek to " << pos << " failed!" << endl; } is.close(); return 0; }
Charles Hicks wrote:
When I run the following program (did not write it) on a 32 bit machine it will not compile and run correctly. However if I compile and run it on my 64 bit machine it works fine.
Thanks for any help you can give!!
I tried compiling on 32-bit with g++ 3.3.3 and it compiled fine. I didn't try running it. Can you be more specific about the error messages you got? -- JDL
On Wednesday 13 October 2004 13:13, John Lamb wrote:
Charles Hicks wrote:
When I run the following program (did not write it) on a 32 bit machine it will not compile and run correctly. However if I compile and run it on my 64 bit machine it works fine.
Thanks for any help you can give!!
I tried compiling on 32-bit with g++ 3.3.3 and it compiled fine. I didn't try running it. Can you be more specific about the error messages you got?
-- JDL
Sorry I should have been more specific, it compiles on my 32 and on my 64 bit machines fine and when I execute it on my 64 bit machine it also runs fine. When I try and execute it on my 32 bit machine I get the following error: charley@dragon:~> g++ -o test test.cpp charley@dragon:~> ./test kb: 1024 mb: 1048576 gb: 1073741824 four_gb: 4294967296 ten_gb: 10737418240 50%File size limit exceeded As I said it runs fine on the 64 bit machine.
Charley wrote:
50%File size limit exceeded
That looks more like a 2GB file size limit than a compile/run error. The file size limit may well be a feature of the C/C++ standard library on 32 bit architectures, even if the kernel can handle more. -- JDL
The first time I try to compile your code (called test.cpp) with : gcc -o test test.cpp a big link error occured. I tryed : gcc -o test test.cpp -lstdc++ Compiled fine and works fine (but I haven't enought space on my hd to run it completly) Le mer 13/10/2004 à 17:30, Charles Hicks a écrit :
When I run the following program (did not write it) on a 32 bit machine it will not compile and run correctly. However if I compile and run it on my 64 bit machine it works fine.
Would appreciate any ideas on this, do you think this is a bug or is there a problem with the compiler or the program?
Thanks for any help you can give!!
Charley
Program
#include <fstream> #include <iostream> #include <iomanip> using namespace std;
int main() { unsigned long long kb = 1024; unsigned long long mb = kb * kb; unsigned long long gb = kb * mb; unsigned long long four_gb = gb * 4; long long ten_gb = gb * 10; int write_count = four_gb / kb;
cout << "kb: " << kb << "\nmb: " << mb << "\ngb: " << gb << "\nfour_gb: " << four_gb << "\nten_gb: " << ten_gb << endl;
unsigned char* buf = new unsigned char[kb]; memset(buf, 0, kb);
double total_writes = write_count; double writes = 0; ofstream os("big_file");
cout << setiosflags(ios::fixed) << setprecision(0);
for (int i = 0; i < write_count; ++i) { os.write((char*)buf, kb);
++writes;
cout << "\r" << setw(3) << (writes / total_writes * 100.0) << "%" << flush; }
os.close();
cout << "\r100%\nFinished..." << endl;
// Open for reading and test seek. ifstream is("big_file"); std::streampos pos = four_gb-1000; // Arbitary position. is.seekg(pos); std::streampos new_pos = is.tellg();
if (pos == new_pos) { cout << "Seek to " << pos << " worked!" << endl; } else { cout << "Seek to " << pos << " failed!" << endl; }
is.close();
return 0; }
On Wednesday 13 October 2004 05:02 pm, Regis FLORET wrote: Are you using a 32 bit or 64 bit machine? Yep I have gotten it to compile (sort of with lots of options on 32 bit) but it will not run to completion. Thanks!
The first time I try to compile your code (called test.cpp) with :
gcc -o test test.cpp
a big link error occured.
I tryed :
gcc -o test test.cpp -lstdc++
Compiled fine and works fine (but I haven't enought space on my hd to run it completly)
Le mer 13/10/2004 à 17:30, Charles Hicks a écrit :
When I run the following program (did not write it) on a 32 bit machine it will not compile and run correctly. However if I compile and run it on my 64 bit machine it works fine.
Would appreciate any ideas on this, do you think this is a bug or is there a problem with the compiler or the program?
Thanks for any help you can give!!
Charley
Program
#include <fstream> #include <iostream> #include <iomanip> using namespace std;
int main() { unsigned long long kb = 1024; unsigned long long mb = kb * kb; unsigned long long gb = kb * mb; unsigned long long four_gb = gb * 4; long long ten_gb = gb * 10; int write_count = four_gb / kb;
cout << "kb: " << kb << "\nmb: " << mb << "\ngb: " << gb << "\nfour_gb: " << four_gb << "\nten_gb: " << ten_gb << endl;
unsigned char* buf = new unsigned char[kb]; memset(buf, 0, kb);
double total_writes = write_count; double writes = 0; ofstream os("big_file");
cout << setiosflags(ios::fixed) << setprecision(0);
for (int i = 0; i < write_count; ++i) { os.write((char*)buf, kb);
++writes;
cout << "\r" << setw(3) << (writes / total_writes * 100.0) << "%" << flush; }
os.close();
cout << "\r100%\nFinished..." << endl;
// Open for reading and test seek. ifstream is("big_file"); std::streampos pos = four_gb-1000; // Arbitary position. is.seekg(pos); std::streampos new_pos = is.tellg();
if (pos == new_pos) { cout << "Seek to " << pos << " worked!" << endl; } else { cout << "Seek to " << pos << " failed!" << endl; }
is.close();
return 0; }
First : My apologize With older version of gcc/g++, I can compile a c++ program with gcc command. Not now. That's why I have so many problems to compile my old wxWidgets progs :) My system is a 9.1 personal customized with apt-get My old one is a 8.0 pro On my 32 bits machines (Athlon XP) the program compiles and works fine until 2 Gb, an error occured due of a system limitation. regards Regis FLORET Le mer 13/10/2004 à 21:20, Charles Hicks a écrit :
On Wednesday 13 October 2004 05:02 pm, Regis FLORET wrote:
Are you using a 32 bit or 64 bit machine?
Yep I have gotten it to compile (sort of with lots of options on 32 bit) but it will not run to completion.
Thanks!
Regis FLORET <r.floret@laposte.net> [Wed, 13 Oct 2004 23:02:43 +0200]:
The first time I try to compile your code (called test.cpp) with :
gcc -o test test.cpp
a big link error occured.
Of course it does, you're using the wrong compiler. gcc is the C compiler, for C++ it's c++. c++ knows which additional libraries are necessary (there are others besides libstdc++) and links them in automatically. Philipp
participants (5)
-
Charles Hicks
-
Charley
-
John Lamb
-
Philipp Thomas
-
Regis FLORET