I have never worked with either C ++ or C ++ / CLI, but I would like to use my own C ++ library in a C # project. I did a bit of work with Google, learned something about C ++ / CLI and decided to give it a start. But I'm not sure that I am doing everything right.
I have the following struct in my own namespace:
avcodec.h
typedef struct AVCodecDescriptor { enum AVCodecID id; enum AVMediaType type; const char *name; const char *long_name; int props; } AVCodecDescriptor;
Now I want to wrap this struct in C ++ / CLI for use in C #:
public ref struct AVCodecDescriptorWrapper { private: struct AVCodecDescriptor *_avCodecDescriptor; public: AVCodecDescriptorWrapper() { _avCodecDescriptor = new AVCodecDescriptor(); } ~AVCodecDescriptorWrapper() { delete _avCodecDescriptor; }
However, it seems like I'm doing something terribly wrong, since I can't even see the struct AVCodecDescriptor fields in C ++ / CLI. Does enum need to be wrapped in a structure? I need to copy them to C ++ / CLI and apply it (well, enum AVCodecID has 350 values ββ- copy / paste seems ridiculous.)
c # clr wrapper c ++ - cli
Acrotygma
source share