Mailinglist Archive: opensuse-programming (47 mails)

< Previous Next >
Re: [suse-programming-e] G++ 3.3.3 Compiler problem.
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;
> }


< Previous Next >
References