So now I'm gonna punt and build an external library that basically passes simple unsigned char pointers back and forth and handles all the fancy C / C++ gymnastics internally.
If you use trunk you can use the system
OpaquePointer type for that instead of PChar. It was introduced exactly for such a purpose: it is a strongly
typed pointer to a structure of unknown - in Pascal - size (in the case of this library known and used in the C++ part).
This is more descriptive and type safe towards its actual use: a Pchar is not the correct type, it is weakly typed, although it works.
In 3.0.4 you can introduce it yourself:
type
OpaquePointer =^TEmptyRecord; // strongly typed pointer to a structure which content itself is only of interest to the external library.
TEmptyRecord = record // it is not really empty but not handled in Pascal
end;
Note this pointer type can also serve other purposes for things in pure pascal code. But its main use is for code like the above.