[fpc-pascal] Calling C functions from FPC

Ken G. Brown kbrown at mac.com
Mon Jan 26 17:41:12 CET 2009

Thank you, that helps.
And I have found documentation in the FPC 2.2.2 download that talks about the Xcode integration templates that handle initial project setup.
I was wondering about that as well.

Ken G. Brown

At 8:53 AM +0100 1/26/09, fpc-pascal-request at lists.freepascal.org apparently wrote:
>Date: Mon, 26 Jan 2009 09:20:29 +0200
>From: Jonas Maebe <jonas.maebe at elis.ugent.be>
>Subject: Re: [fpc-pascal] Calling C functions from FPC
>To: FPC-Pascal users discussions <fpc-pascal at lists.freepascal.org>
>Message-ID: <B0CFA4ED-A184-4CC4-B446-CCB67D9FC19B at elis.ugent.be>
>Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
>On 26 Jan 2009, at 01:24, Ken G. Brown wrote:
>> On MacOS X 10.5.6 Intel targeting 10.3.9 PPC:
>> What are the gotchas with respect to calling C functions from FPC?
>Mark the external C functions you import in your Pascal code as 
>"cdecl", e.g.
>procedure cTest; cdecl; external;
>> What other issues might I have to watch out for?
>Make sure that the types in your Pascal and C code match. The easiest 
>is to use the ctypes unit. Then you can use the common C-types by 
>prefixing them with "c" (e.g., cint, clong, clonglong, cuint, culong, 
>culonglong, cfloat, ...). And don't try to free pointers allocated in 
>the C code in Pascal code and vice versa.

More information about the fpc-pascal mailing list