Board index » cppbuilder » Using Delphi code in BCB

Using Delphi code in BCB


2006-05-16 05:04:08 PM
cppbuilder62
I have some Delphi source code I want to use in a BCB project. Can
Delphi code call C++ functions and vice versa? Can these functions
pass and return data like a pointer or integer or char? Can data like
an array of char or an integer be shared between C++ and Delphi code?
Does it make any difference if it's BCB6 or BDS2006?
Thanks
 
 

Re:Using Delphi code in BCB

"darkknight" < XXXX@XXXXX.COM >wrote in message
Quote

Can Delphi code call C++ functions and vice versa? Can these functions
pass and return data like a pointer or integer or char? Can data like
an array of char or an integer be shared between C++ and Delphi code?
C++ can easily call Delphi ( remember, the VCL is implemented in Delphi).
You can pass most types straight back and forth - ints, strings, class
pointers.
Delphi calling C++ is rather more tricky, but can be done.
Quote
Does it make any difference if it's BCB6 or BDS2006?
You can do it with BCB5 (and I presume BCB6), but BDS2006 should make things
a lot simpler. You've got a full Delphi toolchain in the box, rather than
the limited one which comes with BCB6.
- Roddy
 

Re:Using Delphi code in BCB

"darkknight" < XXXX@XXXXX.COM >wrote in message
Quote
Can Delphi code call C++ functions and vice versa?
C++ code can call Delphi functions very easily. When you add a .pas file to
a C++ project, the Delphi compiler will produce an .hpp header file for the
Delphi code that you can then include into your C++ code.
It is not easy to have Delphi call C++ functions, however.
Quote
Can these functions pass and return data like a pointer or integer or
char?
Yes.
Quote
Can data like an array of char or an integer be shared between C++ and
Delphi code?
Yes. But you have to be careful about it. Arrays work differently in
Delphi than they do in C++ - particularly dynamic arrays.
Quote
Does it make any difference if it's BCB6 or BDS2006?
No.
Gambit
 

{smallsort}

Re:Using Delphi code in BCB

On Tue, 16 May 2006 13:04:04 -0700, "Remy Lebeau \(TeamB\)"
< XXXX@XXXXX.COM >wrote:
Quote

"darkknight" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...

>Can Delphi code call C++ functions and vice versa?

C++ code can call Delphi functions very easily. When you add a .pas file to
a C++ project, the Delphi compiler will produce an .hpp header file for the
Delphi code that you can then include into your C++ code.

It is not easy to have Delphi call C++ functions, however.

Passing a C++ function pointer to Delphi and calling back through
that seems to work. Is there any reason not to do it?
Thanks.