There is开发者_StackOverflow a need to pass CArray instance to an external DLL from my application written in C++ Builder. Is there a way to utilize MFC from C++ Builder? If yes, how?
Addendum: this DLL is not mine and I cannot change it.
C++ Builder doesn't support MFC because the Microsoft and Borland C++ runtimes are incompatible.
See http://www.parashift.com/c++-faq-lite/compiler-dependencies.html#faq-38.9
I don't know if C++ Builder has any kind of MFC support (maybe there is 3rd party open source code for that).
Since the CArray
has few methods, one possible solution is to write a wrapper for it and expose the interface to the dll.
See for example the adapter pattern.
You could use a std::vector instead. The functionality is pretty much the same.
CArray is very similar to a std::vector in that the data is contigous in memory.
The easiest (only safe) way is to pass a pointer to the actual data and a size parameter.
See CArray::getData
Your separate dll shoudln't change the size - if you need to do this use std::Vector
精彩评论