Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all articles
Browse latest Browse all 3046

Wrapper for C++ function to be used in C# (as dll)

$
0
0
Hello,
I want to use this function in my C# project:

Code:

typedef float3 vec;
class OBB {
public:   
vec pos;vec r; vec axis[3];
static OBB OptimalEnclosingOBB(const vec *pointArray, int numPoints);
}

So I need to write a wrapper that will go something like this:

Code:

using namespace System;
using namespace msclr::interop;

#if defined(__cplusplus)
extern "C" {
#endif
    __declspec(dllexport) ??? OEOBB_Wrapper(???, int numPoints);

#if defined(__cplusplus)
}
#endif

String^ OEOBB_Wrapper(float[][], int i) {
// some code casting float[][] to vec *pointArray 
// RerturnValue OptimalEnclosingOBB(const vec *pointArray, int numPoints);
// casting ReturnValue into something C# can read
return ??;
}

But I have 2 problems, The input: vec *pointArray type is not defined in C# so which type I can use instead and how do I cast it? The output: OBB class is not defined in C#, so what kind of return value my wrapper can use instead (after getting the OBB from the function)?

Viewing all articles
Browse latest Browse all 3046

Trending Articles