NietzscheDisciple
Programmer
Hi,
I'm trying to port some code I wrote using DirectSound in C# to Visual C++ (managed). I've got most of it done except for this problem I'm stuck at. I understand that this is a newbie question, so please be gentle
The function I'm having a problem with is CaptureBufferObject->Read(arguments) in C++.
In C#, the function protoype is:
Code:
public Array Read(
int bufferStartingLocation,
Type returnedDataType,
LockFlag flag,
int[] ranks
);
My code has the following usage of the Read method.
Code:
MemBuffShort = (short[])(StreamCaptureBuffer.Read(StreamCapBuffReadPos, typeof(short), LockFlag.None, 50000));
where MemBuffShort = new short[100000];
In C++, the function prototype is:
Code:
public: Array* Read(
int bufferStartingLocation,
Type *returnedDataType,
LockFlag flag,
int ranks __gc[]
);
My problem is with the last parameter: int ranks __gc[]
I tried the following:
Code:
// With the variable declarations
static System::Int32 CapBuffPara[] = new System::Int32[] { 50000 };
// Calling the Read method
MemBuff = StreamCapBuffer->Read(StreamCapBuffReadPos, __typeof(int), LockFlag::None, CapBuffPara);
CapBuffPara[] has been declared as a private variable and then instantiated in the Form1 constructor as follows:
Form1(void)
{
CapBuffPara = new int __gc[1];
CapBuffPara[0] = 5000;
InitializeComponent();
}
However, I get the following error message:
error C2440: '=' : cannot convert from 'System::Array __gc *' to 'int __gc[]'
1. The tooltip on CapBuffPara shows:
int (ProjName)::Form1::CapBuffPara __gc[]
2. The function definition requires the last argument to be int __gc[]
So I don't understand why the compiler says it cannot convert from System::Array __gc * to int __gc.
How do I solve this problem? What needs to be changed?
Thanks for your help!
I'm trying to port some code I wrote using DirectSound in C# to Visual C++ (managed). I've got most of it done except for this problem I'm stuck at. I understand that this is a newbie question, so please be gentle
The function I'm having a problem with is CaptureBufferObject->Read(arguments) in C++.
In C#, the function protoype is:
Code:
public Array Read(
int bufferStartingLocation,
Type returnedDataType,
LockFlag flag,
int[] ranks
);
My code has the following usage of the Read method.
Code:
MemBuffShort = (short[])(StreamCaptureBuffer.Read(StreamCapBuffReadPos, typeof(short), LockFlag.None, 50000));
where MemBuffShort = new short[100000];
In C++, the function prototype is:
Code:
public: Array* Read(
int bufferStartingLocation,
Type *returnedDataType,
LockFlag flag,
int ranks __gc[]
);
My problem is with the last parameter: int ranks __gc[]
I tried the following:
Code:
// With the variable declarations
static System::Int32 CapBuffPara[] = new System::Int32[] { 50000 };
// Calling the Read method
MemBuff = StreamCapBuffer->Read(StreamCapBuffReadPos, __typeof(int), LockFlag::None, CapBuffPara);
CapBuffPara[] has been declared as a private variable and then instantiated in the Form1 constructor as follows:
Form1(void)
{
CapBuffPara = new int __gc[1];
CapBuffPara[0] = 5000;
InitializeComponent();
}
However, I get the following error message:
error C2440: '=' : cannot convert from 'System::Array __gc *' to 'int __gc[]'
1. The tooltip on CapBuffPara shows:
int (ProjName)::Form1::CapBuffPara __gc[]
2. The function definition requires the last argument to be int __gc[]
So I don't understand why the compiler says it cannot convert from System::Array __gc * to int __gc.
How do I solve this problem? What needs to be changed?
Thanks for your help!