Discussion:
Delphi to C++ issue
(too old to reply)
MwnN
2007-08-11 21:27:51 UTC
Permalink
Hi,

Having an issue with a Delphi component in BDS C++ 2006. As far as I know
the Delphi component was developed in Delphi 2005.



Delphi code

TBuffer = array[1..255] of char;

function ChangeData(Buffer: PAnsiChar): TBuffer;




BCB Code

typedef char TBuffer [255];

TBuffer __fastcall ChangeData(char * Buffer);



Error message I get is

E2091 Functions cannot return arrays or functions


I was reading searches in google that maybe a define might be needed for it
to be used in BDS C++ 2006 but I'm not sure what..

Thanks,
MwnN
Liz
2007-08-12 15:48:31 UTC
Permalink
Post by MwnN
Delphi code
TBuffer = array[1..255] of char;
function ChangeData(Buffer: PAnsiChar): TBuffer;
BCB Code
typedef char TBuffer [255];
TBuffer __fastcall ChangeData(char * Buffer);
I can't imagine that this ever worked in C++.

Try returning a pointer instead
--
liz
MwnN
2007-08-12 20:18:05 UTC
Permalink
Post by Liz
I can't imagine that this ever worked in C++.
Try returning a pointer instead
--
liz
I Liz,

I never worked in C++, but did work in Delphi (as it is a Delpi Component),
the C++ code is what BDS 2006 generated when creating the hpp files, is
there anything I can add to the Delphi code to make the hpp file generation
use a pointer instead of the array its currently using so the component will
still work in Dephi and C++.

Thanks again,
MwnN
Clayton Arends
2007-08-13 06:37:44 UTC
Permalink
Instead of returning a TBuffer you can try passing it as a var argument.

procedure ChangeData(InBuffer : PAnsiChar; var OutBuffer : TBuffer);

HTH
- Clayton

Continue reading on narkive:
Loading...