Hello I have been using QuantLib in Visual Studio 2010, and have come across the following issues:
1) There is an %include in the SWIG wrapper which #defines SWIGSTDCALL to nothing if the SWIG target is CSharp. This causes P/Invoke to throw an exception under the .NET 4.0 Framework. (see http://msdn.microsoft.com/en-us/library/ee941656\(v=VS.100).aspx, "Platform Invoke") because the wrapper functions are not __stdcall.
2) In order to use the numerical integration classes from C# I had to add the following code to the SWIG wrapper, perhaps you could consider integrating it into the next release:
=== types.i ===
...
#elif defined(SWIGCSHARP)
// The following macro defines a typemap between boost::function<RTYPE(PTYPEA)> and a corresponding .NET delegate type
%define %cs_func1(RTYPE, friendlyRTYPE, PTYPEA, friendlyPTYPEA)
#define BFUNC boost::function<RTYPE(PTYPEA)>
#define DELEGATE friendlyPTYPEA##To##friendlyRTYPE##Delegate
%pragma(csharp) modulecode=%{
public delegate RTYPE friendlyPTYPEA##To##friendlyRTYPE##Delegate(PTYPEA a);
%}
%typemap(ctype) BFUNC, BFUNC& "void*"
%typemap(in) BFUNC { $1 = (RTYPE (__stdcall *)(PTYPEA)) $input; }
%typemap(in) BFUNC& { $1 = (RTYPE (__stdcall *)(PTYPEA)) $input; }
%typemap(imtype, out="IntPtr", noblock=1) BFUNC, BFUNC& { NQuantLibc.DELEGATE }
%typemap(cstype, out="IntPtr", noblock=1) BFUNC, BFUNC& { NQuantLibc.DELEGATE }
%typemap(csin, noblock=1) BFUNC, BFUNC& { $csinput }
#undef DELEGATE
#undef BFUNC
%enddef
// Typemap boost::function<double(double)> to NQuantLibc.DoubleToDoubleDelegate
%cs_func1(double, Double, double, Double)
#endif
...
=== integrals.i ===
...
%define INTEGRATION_METHODS
...
#elif defined(SWIGCSHARP)
Real Call(boost::function<double(double)> f, Real a, Real b)
{
return (*self)(f, a, b);
}
#endif
The SWIGSTDCALL issue was solved. Functions were given another implementation, but you can resubmit your code as a pull request on GitHub if you think it's more convenient than the current interface.