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
does using namespace std;
and it also pollutes the global namespace with all of its typedefs. The problem with the line:
typedef const NRvector<Int> VecInt_I;
and the other lines involving Int
is because Int
is resolved to System::Int
(vcl.h
includes this function's definition and also using namespace System;
) .
There are further errors with
typedef const NRmatrix<Char> MatChar_I;
because of ambiguity between System::Char
(a type) and Char
defined by nr3.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 (say NR3
) , and take out using 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.