views:

249

answers:

4

Hello.

There is 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.

A: 

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.

Nick D
A: 

You could use a std::vector instead. The functionality is pretty much the same.

Goz
This DLL is not mine and I cannot change it's interface. It expects CArray and I can do nothing with it.
FractalizeR
+2  A: 

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

atomice
As a consequence of this you will very likely find the external DLL will not work with C++ Builder.
atomice
A: 

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

Martin Beckett