Using C++Builder code in Delphi

I am trying to use the {$L xxxx.obj} documented feature with Delphi 4.

The OBJ file is generated with C++Builder 4.

I get the following error message :

Unsatisfied forward declaration or uncorrect external declaration.

Can someone tell me why ? I am thinking of a problem of correspondence between Delphi and C++ types...
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

godchaAuthor Commented:
Edited text of question.
godchaAuthor Commented:
Edited text of question.
did you specify the correct path? :

{$L myprogramdir/test/testing.obj}
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Note, however, that this will only work if you have _not_ used any of the C
runtime library routines in the C++ code, and won't work with
C++ classes contained in the OBJ.

the following was a test with a teamb bloke a last year with another bloke having same problem as you and generates same error:

C (compiles to cobj.obj);
//cobj source for newsgroup post
//function prototype
extern "C" void __stdcall thefunction();
//function implementation
void __stdcall thefunction(){
//end of C source
Delphi unit (only unit of project1.exe):
unit Unit1;
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,   StdCtrls;
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    { Private declarations }
    { Public declarations }
  Form1: TForm1;
{$R *.DFM}
{$L cobj.obj}
procedure thefunction; stdcall; far; external;
procedure TForm1.Button1Click(Sender: TObject);
When trying to compile, the only error message is this:
"unsatisfied forward or external declaration: thefunction"

but when changing the c routine to:

 #pragma option push -V?-
//undocumented stuff

extern "C" void __stdcall thefunction();

//function implementation
void __stdcall thefunction(){
#pragma option pop

it them compiled and worked and delphi found the function...maybe it help you ?
hope so
Regards Barry

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
In additionto Barry's comment:

Some C library functions can quite easily emulated. If you need that I can provide these functions:

function _malloc(Size : Integer): Pointer; cdecl;
procedure _free(Ptr : Pointer); cdecl;
function _calloc(NItems : Integer; Size : Integer) : Pointer; cdecl;
function _realloc(block : Pointer; Size : Integer) : Pointer; cdecl;

function _strcat(Dest, Source: PChar): PChar; cdecl;
function _strlen(P1: PChar): Integer; cdecl;
function _strcpy(Dest, Source: PChar): PChar; cdecl;
function _strncmp( const s1 : Pchar;
                   const s2 : Pchar; maxlen : Integer) : Integer; cdecl;
function _strncpy( dest : Pchar;
                   const src : Pchar; maxlen : Integer) : PChar; cdecl;
function _strtok(const s1 : PChar; const s2 : PChar) : PChar; cdecl;

function _tolower( ch : Integer ) : Integer; cdecl;

procedure _memset(P: Pointer; Value: Integer; Count: Cardinal); cdecl;

function _memcpy(Dest, Source: Pointer; Len: Integer): Pointer; cdecl;
function _memcmp( const s1   : PByteArray;
                  const s2   : PByteArray;
                  const Size : Integer  ): Integer; cdecl;

function _ltoa(Value : LongInt; Str : PChar; Radix : Integer) : PChar; cdecl;
function _exp( value : double ) : double; cdecl;
function _floor( value : double ) : double; cdecl;
function _log( value : double ) : double; cdecl;
function _sqrt( value : double ) : double; cdecl;
function _fabs( value : double) : double; cdecl;
function _pow( x : double; y : double ) : double; cdecl;

procedure __turboFloat; cdecl;
procedure __streams; cdecl;

It's a unit of ~600 lines and I got it with an uncomplete PNG implementation from Zwabbert. Note: I haven't tried the code yet!

Whoever needs the code call me at

Ciao, Mike
some ti's on the matter

there is a delphi ti as well but i could'nt find it.
godchaAuthor Commented:
To Inthe

Why won't it work with code using C runtime library routines ?
 i have no idea why not but it came from a teamb member and they usually know what they are are on about ;-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.