This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


On Mon, Mar 29, 2004 at 04:50:16PM +0800, Subrata Basak wrote:

> 
> 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 stream, 
> but when I run my program, it creates only 254 file stream, 
> after that assertion occurs!!!!

This sounds like an artificial limit:

254 + stdin + stdout + stderr = 257

i.e. fails when number of open file descriptors > 256

Were you in the same environment each time you ran the program?
Have you checked the value of "ulimit -n" ?

As Paolo suggests, something's possibly broken with your GCC 3.3.3
installation, try gcc-help@gcc.gnu.org and provide more details of
your environment and what goes wrong (e.g. the value of errno)

jon


>                
> My Code :
> ============================
> #include <assert.h>
> #include <string>
> #include <fstream>
> 
> const int MAX_STREAM = 1000;
> 
> using namespace std;
> 
> int main(int argc, char* argv[])
> {
>         ifstream in[MAX_STREAM];
>         string file("boo");
> 
>         for ( int i=0; i != MAX_STREAM; i++ )
>         {
>                 in[i].open(file.c_str());
>                 cout << "i : " << i << endl;
>                 assert(in[i]);
>         }
>         return 0;
> }
> ============================
> 
> But, if I use the exactly same program with the following
> compiler, 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
> 
> 

-- 
VOTE, v.  The instrument and symbol of a free man's power to make
a fool of himself and a wreck of his country.
	- Ambrose Bierce, 'The Devil's Dictionary'


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]