File Stream Open Problem with g++ 3.3.3 and libstdc++.so.5

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi

I am facing one problem when I complie and run my code
with the following compiler and standard C++ library :

Compiler Used : g++ 3.3.3
Standard Library Used : libstdc++.so.5

Problem : I am supposed to create 1000 file streams, 
but when I run my program, it creates only 254 file streams, 
after that assertion occurs!!!!

OUTPUT :
========
$ echo $SHELL
/usr/bin/sh
$ 
$ ulimit -n
50000
$ 
$ ./a.out
i : 253
errno : 24
Assertion failed: in[i], file main.cpp, line 28
Abort - core dumped
$
========

MY CODE :
==================================================
#include <sys/errno.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <string>

extern int errno;

const int MAX_STREAM = 1000;

using namespace std;

int main(int argc, char* argv[])
{
        ofstream in[MAX_STREAM];
        string file("boo");

        for ( int i=0; i != MAX_STREAM; i++ )
        {
                in[i].open(file.c_str(), ios::out);

                if ( errno > 0 ) {

                    cout << "i : " << i << endl;
                    cout << "errno : " << errno << endl;

                } // end of "if ( errno > 0 ) {"

                assert(in[i]);
        }
        return 0;
}
===================================================
But, if I compile the exactly same program with the 
following compiler and run the executable under the
same environment as above, it is running without 
any problem and 1000 file streams are created 
smoothly without any assertion.

Compiler Used : g++ 2.95.3

Standard Library Used : libstdc++.so.2.10.0

Anybody can help me to overcome this problem with
g++ 3.3.3 compiler and libstdc++.so.5 library.

With Very Best Regards

Subrata Basak
MediaRing Ltd., Singapore


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux