zgn
zgn

Reputation: 315

can i implement `_exit`c function in delphi?

I want to consume c obj files in delphi xe3.

When linked obj files, shows this error:

`[dcc32 Error] Unit1.pas(149): E2065 Unsatisfied forward or external declaration: '_exit'`

can i implement _exit function?

Upvotes: 2

Views: 121

Answers (1)

David Heffernan
David Heffernan

Reputation: 612934

Yes you can indeed do this. Typically you will link the .obj file to a single unit in your project. Implement the exit function in that unit and the Delphi linker will find it.

....

implementation

....

{$LINK foo.obj}

procedure _exit(status: Integer); cdecl;
begin
  // your implementation goes here
end;

As I've illustrated this you place the function in the implementation section of the unit. It does not need to be visible externally to the unit.

You might have multiple different units that link to C objects, in which case you can place your C runtime functions, like exit, in a single unit, and use that from each other unit that links to C objects. In that scenario then you need to expose each function in the interface section so that the linker can see the function.

Upvotes: 1

Related Questions