This is my first attempt at creating a C# wrapper to a C lib. The SDK is 3rd party and outside my control:
sdk_defines.h
#ifndef SDK_CHAR_T
#define SDK_CHAR_T
typedef char sdk_char_t;
#endif /* SDK_CHAR_T */
#ifndef SDK_CSTR_T
#define SDK_CSTR_T
typedef const sdk_char_t* sdk_cstr_t;
#endif /* SDK_CSTR_T */
sdk.h
sdk_cstr_t SDK_API
sdk_get_version(void);
My C# wrapper:
[DllImport("sdk.dll", CharSet = CharSet.Ansi)]
private static extern string sdk_get_version();
Any call to sdk_get_version causes a crash, no exception. I have a feeling it's the return type, but how do I properly marshal it in C#?