Efficient and safe passing of data over C-style plugin interface

103 views Asked by At

Currently I am developing a plugin interface for my C++ application and am struggling with how to pass my data in an efficient way. I have read a lot of posts, tutorials and so on, and now decided to just use a "proxy" C-style API.

If I got it right I have to convert my classes (or more specifically the data members) to POD types somehow, but I want to circumvent unnecessary copy operations (the passed data can be quite large under special circumstances).

I) Am I right that the layout of data members inside C++ classes is up to the compiler and I thus cannot just pass a pointer to the first data member to the plugin?

II) I could move the data members to structs, which in turn would be the only data members (of POD type) of my classes then. Then I could just pass the pointers to those structs to access my data. Is there anything wrong with this approach, especially concerning data padding?

Thanks in advance.

0

There are 0 answers