I tried to use numerical recipes version 3 within my c++ project using c++ Builder from RAD XE 2.
However, the compiler complains about all lines like
typedef const NRvector<Int> VecInt_I;
typedef NRvector<Int> VecInt, VecInt_O, VecInt_IO;
... saying "ungültige Argumentenliste" (sorry for German), which translates to invalid list of arguments
.
Using the same file in a simple empty program works fine, though...
But if I write at the beginning of my c++ project
#include <vcl.h>
#pragma hdrstop
#include "nr3.h"
int main(){
return 0;
}
... it gives me this error.
Is there a compiler-option that is causing this? Maybe some C++ Builder project setting?
nr3.h
doesusing namespace std;
and it also pollutes the global namespace with all of its typedefs. The problem with the line:and the other lines involving
Int
is becauseInt
is resolved toSystem::Int
(vcl.h
includes this function's definition and alsousing namespace System;
) .There are further errors with
because of ambiguity between
System::Char
(a type) andChar
defined bynr3.h
.There's no simple fix.
nr3.h
has multiple serious issues, not just that it pollutes the global namespace. As a band-aid you could edit it so that it puts all of its definitions in a namespace (sayNR3
) , and take outusing namespace std;
. But even if you get it compiling, this code is so dreadful that you will run into many other issues later on. My advice would be to simply not use it, and either write your own code based on its algorithms or look for some other solution entirely.