problem including <fstream.h>
Matthias
12-03-2002, 07:38 AM
Hi
I'm using the c++ version 2.10 of the recipes on a msvc6 compiler.
If I try to include <fstream.h> together with "nr.h" I receive lots of compiler errors. The order in which I include the files has some effect on the number and kind of errors that appear, but in both cases it won't work.
Using <fstream> instead, works fine; but unfortunately I need to use the recipes together with other libraries that include <fstream.h> - so this is no solution for me.
Does anyone know, if there's a chance to use the c++ recipes together with <fstream.h>?
Best regards,
Matthias
Saul Teukolsky
12-03-2002, 09:24 AM
Hi Matthias,
I haven't tried this, but you should be able to edit nr.h to replace fstream by fstream.h. You should do this also in nrtypes_nr.h and nrtypes_lib.h. Only 3 recipes include fstream: fourew, fourfs, and spctrm. If you use any of them you can make the change there. Many drivers include fstream. If you're going to use them, you might want a little perl script to edit them en masse.
Let us know if this works!
Saul Teukolsky
Matthias
12-04-2002, 06:00 AM
Thanks for your proposals, but unfortunately they did not work.
After changing the <fstream> to <fstream.h> in the files nr.h, nrtypes_nr.h and nrtypes_lib.h as you proposed, exactly the same errors occured as befor. The only difference now is, that these errors occur even without including <fstream.h> expilicitly in my code (only including "nr.h").
I will now specify the problem more in detail:
First of all ta code, which I use for testing: It consists only of four lines:
#include <fstream.h>
#include "nr.h"
void main(void)
{ }
When I try to compile this I receive 6 error messages, that occur in the files nrutil_nr.h, nrtypes_ne.h and nr.h.
It is the error C2872 "ambigous symbol" (I don't know whether this is the correct translation of the error's name, but I have only the German version of msvc6).
Here is the complete output of my compiler (unfortunately in German):
Kompilierung läuft...
ThresholdAnalysis.cpp
c:\nr\cpp\other\nrutil_nr.h(53) : error C2872: 'cerr' : Mehrdeutiges Symbol
c:\nr\cpp\other\nrutil_nr.h(54) : error C2872: 'cerr' : Mehrdeutiges Symbol
c:\nr\cpp\other\nrutil_nr.h(54) : error C2679: Binaerer Operator '<<' : Kein Operator definiert, der einen rechtsseitigen Operator vom Typ 'const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' akzeptiert (oder keine geeignete Konvertierung moeglich)
c:\nr\cpp\other\nrutil_nr.h(55) : error C2872: 'cerr' : Mehrdeutiges Symbol
c:\nr\cpp\other\nrtypes_nr.h(90) : error C2872: 'fstream' : Mehrdeutiges Symbol
c:\nr\cpp\other\nr.h(411) : error C2872: 'ifstream' : Mehrdeutiges Symbol
Fehler beim Ausführen von cl.exe.
ThresholdAnalysis.exe - 6 Fehler, 0 Warnung(en)
Best regards,
Matthias
Saul Teukolsky
12-04-2002, 08:12 AM
Hi Matthias,
Sounds like a problem with your compiler setup. Lots of people have run with the Microsoft compiler (with just <fstream>) with no problem.
Good luck!
Saul Teukolsky
Kevin Dolan
12-05-2002, 09:27 AM
Matthias,
You also need to replase the #include <iostream> with #include <iostream.h> in the nrutil_nr.h file.
Kevin