cowabunga
February 2nd, 2009, 03:37 AM
Hi,
I have a static lib - and I have created a wrapper dll for exporting some functions from the static lib. Now, I am trying to access the exported functions from Managed C++ on Visual Studio 2005. I have an "out" parameter and I am using Interop services. But I get a compiler error saying
error C2039: 'Out' : is not a member of 'System::Runtime::InteropServices'
Giving my code snippet below:
#using <mscorlib.dll>
using namespace System;
using namespace System::Runtime::InteropServices;
public ref class LibWrap
{
public:
[DllImport("demo.dll", SetLastError=true,
CallingConvention=CallingConvention::StdCall)]
static void Create([System::Runtime::InteropServices::Out] IntPtr handle);
[DllImport("demo.dll", SetLastError=true,
CallingConvention=CallingConvention::StdCall)]
static void Initialize(IntPtr hIpoptHandle, String^ paramsFile);
};
int main(array<System::String ^> ^args)
{
IntPtr handle;
LibWrap::Create([System::Runtime::InteropServices::Out] handle);
LibWrap::Initialize(handle, "abc");
Console::WriteLine("Hello World");
}
On compilation I get these errors,
error C2143: syntax error : missing ')' before '['
error C2660: 'LibWrap::IpOptCreate' : function does not take 0 arguments
error C2039: 'Out' : is not a member of 'System::Runtime::InteropServices'
error C2065: 'Out' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'handle'
error C2059: syntax error : ')'
Any pointers on the same would be appreciated !
Thanks!
I have a static lib - and I have created a wrapper dll for exporting some functions from the static lib. Now, I am trying to access the exported functions from Managed C++ on Visual Studio 2005. I have an "out" parameter and I am using Interop services. But I get a compiler error saying
error C2039: 'Out' : is not a member of 'System::Runtime::InteropServices'
Giving my code snippet below:
#using <mscorlib.dll>
using namespace System;
using namespace System::Runtime::InteropServices;
public ref class LibWrap
{
public:
[DllImport("demo.dll", SetLastError=true,
CallingConvention=CallingConvention::StdCall)]
static void Create([System::Runtime::InteropServices::Out] IntPtr handle);
[DllImport("demo.dll", SetLastError=true,
CallingConvention=CallingConvention::StdCall)]
static void Initialize(IntPtr hIpoptHandle, String^ paramsFile);
};
int main(array<System::String ^> ^args)
{
IntPtr handle;
LibWrap::Create([System::Runtime::InteropServices::Out] handle);
LibWrap::Initialize(handle, "abc");
Console::WriteLine("Hello World");
}
On compilation I get these errors,
error C2143: syntax error : missing ')' before '['
error C2660: 'LibWrap::IpOptCreate' : function does not take 0 arguments
error C2039: 'Out' : is not a member of 'System::Runtime::InteropServices'
error C2065: 'Out' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'handle'
error C2059: syntax error : ')'
Any pointers on the same would be appreciated !
Thanks!