|
|
bug in XCode 2.4.1/gcc-4.0/x86_64 when declaring large number of ofstreams
|
|
|
|
Fresh-Faced Recruit
Join Date: Mar 2007
Status:
Offline
|
|
Dear all,
I want to open a large number of files (50-100) in a 64-bit C++ program on my mac Pro. However, when compiled under debug using the architecture i386 in Xcode, it runs fine. However, when the architecture flag is set to x86_64 and compilation is under relase, then I get a segmentation fault after the 18th fopen-statement.
the main program I use is
using namespace std;
int main (int argc, char * const argv[]) {
ofstream datafile1("file1");
cout<<endl<<"\n done file1..."<<endl;
ofstream datafile1("file2");
cout<<endl<<"\n done file2..."<<endl;
// and so on until
ofstream datafile1("file50");
cout<<endl<<"\n done file50..."<<endl;
return 0;
}
Anyone knows whether this is a known bug in gcc/Xcode??? It seems that it was a bug in older 32 bit gcc versions....
any hint is appreciated!
Chris
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Mar 2007
Status:
Offline
|
|
I forgot to mention, that the code was compiling an running fine under the architecture ppc64 on a powermac G5.
chris
|
|
|
|
|
|
|
|
|
Forum Regular
Join Date: Sep 2003
Location: San Diego
Status:
Offline
|
|
That's a good question, and i really don't know the answer. (I'm stuck on a PowerPC machine here, and I haven't done any 64bit programming). If you don't get an answer here, you're best bet would be to describe the problem on one of Apple's developer mailing lists. I know you'll get a helpful response there...
|
|
|
|
|
|
|
|
|
Dedicated MacNNer
Join Date: Apr 2004
Status:
Offline
|
|
why not just use fprintf() if you're just printing straight char stuff to files? I always found c++'s file streams or whatever they're called to be crazy anyhow. ('course, I only looked at 'em for like 30 minutes, but...)
|
|
|
|
|
|
|
|
|
Senior User
Join Date: Mar 2007
Location: San Jose
Status:
Offline
|
|
Is there a reason you're redeclaring the variable datafile1 in the example you gave, or is that just a typo? And where's the fopen() you're using? Mixing C++ iostreams and C stdio can have odd results. If you give us the failing testcase, it'll be a lot easier to see what the issue is.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|