cdecl

The cdecl modifier can be used to declare a function that uses a C type calling convention. This must be used when accessing functions residing in an object file generated by standard C compilers. It allows to use the function in the code, and at linking time, the object file containing the C implementation of the function or procedure must be linked in. As an example:
 program CmodDemo;
 {$LINKLIB c}
 Const P : PChar = 'This is fun !';
 Function strlen (P : PChar) : Longint; cdecl; external name 'strlen';
 begin
   WriteLn ('Length of (',p,') : ',strlen(p))
 end.
When compiling this, and linking to the C-library, the strlen function can be called throughout the program. The external directive tells the compiler that the function resides in an external object filebrary with the ’strlen’ name (see 8.6).

Remark: The parameters in our declaration of the C function should match exactly the ones in the declaration in C.