C to Pascal

 C type              Pascal type
-------------------------------
 unsigned char       byte
 char                char
 char name[arSize]   array [0..arSize - 1] of Char
 int                 integer
 unsigned int        word
 long                longint
 unsigned long       longint
 float               single
 double              double
 char far *          PChar
 char *              PChar if large memory model, Word in small and medium
 SomeType far *      Var aName: SomeType
                     or PSomeType (type PSomeType = ^SomeType) if you
                     need the option to pass Nil as a value
 struct              record
 union               record with variants
 enum                enumerated type with compiler switch $Z+ set
                     (default is $Z-!)
 

Q:  If the argument of a C function is of type float, how should it be declared in Pascal: real, single or double?

A:  Guaranteed "real" is NOT the answer. The Real data type is a 6-byte floating point number that's completely specific to Borland Pascal. Single and Double correspond precisely to the IEEE standard 4-byte and 8-byte floating point types. There's also an Extended type which is the 10-byte floating point format used internally by the numeric co-processor.  A "C" float is a Pascal SINGLE! The double type is called double in C, too.

type Plong = ^longint;

function foo
  ( arg1 : Plong; arg2: Pchar; arg3, arg4, arg5, arg6 : double ) : longint;

This was translated from the following C declaration:

long foo( long FAR * arg1,
          char FAR * arg2
          float arg3,
          float arg4,
          float arg5,
          float arg6 );

In general, when an argument in a C function contains "FAR *" and it's NOT a pointer-to-char, instead of making the corresponding Pascal argument a pointer, you simply make it a VAR parameter. So your function header would begin:

       function foo(VAR arg1 : Long; ...

Q (follow up):  Since Foo *returns* a pointer, should arg1, the longint pointer, be declared as a variable parameter in the declaration of Foo?

A:         If this weird foo function returns a pointer to its first arguement, you can do it like this:

       FUNCTION Foo(VAR bar : LongInt; ...) : PLongInt;
       BEGIN
         ...
         Foo := @bar;
       END;

       ... or you can do it like this:

       FUNCTION Foo(bar : PLongInt; ...) : PLongInt;
       BEGIN
         ...
         Foo := Bar;
       END;

       In the latter case, you'll have to dereference Bar every time you use it in the function. The former is probably easier on YOU.  If the implementation of the function is in a DLL written by others and it does a lot more than return the pointer, the second option may be the only one open to you.
Hex to Decimal