It depends on the decoration of the name used by any C compiler that you use. For example, the 32-bit bcc32 compiler will decorate Test
how _Test
. Therefore, the Delphi code to link to it should be:
function Test(): Integer; cdecl; external name '_Test';
, , . , C obj .
, ++, C.
extern "C"
C. C. .cpp .c , C.
C, malloc
, System.Win.Crtl
Delphi.
, , , , main
C-. C- C, , , . . C Delphi. main
Delphi, .
C main
int main(void)
, C :
int __cdecl Test(void)
, __cdecl
, :
int Test(void)
:
int Test(void)
{
return 12;
}
, C ++. , , MSVC, :
cl /c source.c
Delphi
{$APPTYPE CONSOLE}
{$L Source.obj}
function Test: Integer; cdecl; external name '_Test';
begin
WriteLn(Test);
end.
12