P
Peter Hartlén
Hi!
I'm playing with the thought of creating my own .NET wrapper for a C++ SDK
(TomTom 5 SDK in this case).
What are my alternatives? Considering there are function calls with
non-blittable structures, a custom C-wrapper which exposes each function
call with only non-struct arguments sounds most logical. But perhaps it is
possible to use .NET right away?
For example, a simple function (using dumpbin) for retrieveing the
sdk-version has the following export:
?GetSDKVersion@CTomTomAPI@@QAAHPAUTError@1@PAUTVersion@1@@Z
The function has the following definition:
INT GetSDKVersion(TError* aError, TVersion* aVersion)
TError has the following definition:
int iError
TVersion has the following definitions:
char iVersion[16];
int iBuildNumber;
What would your recommendation be?
1. Create a C++-wrapper that exposes the function calls like this:
GetSDKVersion(int iError, char cVersion[16], int iBuildNumber) so it's easy
to call the functions from a managed environment. I don't have much
C-experience so this is not a trivial thing for me in the initial phase.
2. Create the structures/classes in C#-manner and use some tricks (I believe
Alex Feinman wrote an article about how to pinvoke complex structures but I
have lost the link ).
Thanks in advance,
Peter
I'm playing with the thought of creating my own .NET wrapper for a C++ SDK
(TomTom 5 SDK in this case).
What are my alternatives? Considering there are function calls with
non-blittable structures, a custom C-wrapper which exposes each function
call with only non-struct arguments sounds most logical. But perhaps it is
possible to use .NET right away?
For example, a simple function (using dumpbin) for retrieveing the
sdk-version has the following export:
?GetSDKVersion@CTomTomAPI@@QAAHPAUTError@1@PAUTVersion@1@@Z
The function has the following definition:
INT GetSDKVersion(TError* aError, TVersion* aVersion)
TError has the following definition:
int iError
TVersion has the following definitions:
char iVersion[16];
int iBuildNumber;
What would your recommendation be?
1. Create a C++-wrapper that exposes the function calls like this:
GetSDKVersion(int iError, char cVersion[16], int iBuildNumber) so it's easy
to call the functions from a managed environment. I don't have much
C-experience so this is not a trivial thing for me in the initial phase.
2. Create the structures/classes in C#-manner and use some tricks (I believe
Alex Feinman wrote an article about how to pinvoke complex structures but I
have lost the link ).
Thanks in advance,
Peter