1. I'm not sure, which types i should use for exported library methods in order to provide compatibility
for C++ (or C#) host applications running under windows and Linux. Especially for UTF-16 strings.
I can create some packed record that will use ctypes and Pwidechar for strings.
C++ host application will pass pointer to memory that contain structure, i should be able to use it from pascal library, right?
But how to return complicated result like record with UTF-16 strings from exported pascal library method to C++ host application?
2. What if host application will be another C++ library rather than exe?
In that case, can pascal still return compilated record with utf-16 strings?
You need to make sure that the same module that allocated something is the one that frees it. So either the application provides your library with a buffer and size and you complain if the buffer size is too small (preferably returning the new size) or you allocate the buffer yourself and also provide a function for the application to free your buffer again.Let me put some example, for simplicity, targeted only for windows (so i use PWideChar).