No, I don't think it's a problem with g++, and I'd advise waiting until the
bug fix version in August before using g++ 3.xx in a production
environment. The C++ problems with g++ were to do with standards
compliance, templates, C++ strings and the like. You wouldn't have got it
to compile if you had hit one of those.
Since it works stand alone, but not as a package, I would suggest that the
first place to look is whether you are hitting a per process file
descriptor limit. The main problem with your code is that you don't check
the return value of the fopen() call. If it won't read, then fopen() is
probably failing and you need to find the value of errno, which will give
you a clue.
If running out of file descriptors is a problem you have two things to do:
1. Check the rest of the code to make sure you are closing files when you
finish with them - you'd be surprised how often files don't get closed :)
2. You need to take a look at man getrlimit() for info on how to set system
resource limits from within a program.
The following code call early in main will give your program the maximum
number of files available, without recompiling the kernal:
#include
#include
#include
int main()
{
// stuff
rlimit info;
getrlimit(RLIMIT_NOFILE,&info);
info.rlim_cur = info.rlim_max;
setrlimit(RLIMIT_NOFILE,&info);
getrlimit(RLIMIT_NOFILE,&info);
// stuff
}
----- Original Message -----
From: "Karol Pietrzak"
To: "Gunter Laky" ;
Sent: Wednesday, July 04, 2001 4:56 PM
Subject: Re: [SLE] C++ problem
| On 4 Jul 2001, Gunter Laky wrote:
|
| > The follwoing is a part of a reading routine (reading a small
| > ascii table, which I attached the first 10 lines of the file at
| > the bottom of this message) of a large package program for data
| > analysis tool.
| >
| > It turned out that this reading process can be performed
| > if it stands alone but cannot be performed if it is included in
| > the whole package. In both case, there are no compile errors. We
| > wonder whether it may have to do with some performance in gcc
| > library.
| >
| > Did you ever heard of such problems?
|
| Well, we don't know what version SuSE you are using, nor the gcc
| / libstdc++* versions.
|
| Although my experience with C++ is very limited, here's what I
| would try:
|
| Just to make sure it's not a gcc problem (versions prior to 3.0
| did not support ALL C++ features), install gcc 3.0.
|
| The SuSE Linux Knowledge Portal has a great article (along with
| RPM links) on GCC 3.0 @
| http://portal.suse.de/en/content.php?3occccccccccccccccccccmccccc
| cccccocccccccococcccccccccccccccc&content/desktop/gcc30.html .
| --
| noodlez: Karol Pietrzak
| PGP KeyID: 0x3A1446A0
[...]