[fpc-pascal] mixing C and Pascal and function pointers

Ken G. Brown kbrown at mac.com
Fri Oct 20 20:19:38 CEST 2006


I've been experimenting with calling C routines in a library from Pascal. This seems to work:

In the Pascal source do
	
Procedure croutine;	cdecl; alias : '_croutine'; External;

If there is trouble finding the routines when building, you can give the location of the routines in the Pascal source file with:

{$L libcroutines.a}	

When compiling, the 'lib' is automatically added to the front of the file name for the library source.

So far I have passed an SInt32 to the C routines so maybe you could pass the appropriately sized variable.
 
Good luck.
Ken

>Date: Thu, 19 Oct 2006 07:44:30 -0700 (PDT)
>From: "Leonardo M. RamÈ" <martinrame at yahoo.com>
>Subject: Re: [fpc-pascal] mixing C and Pascal and function pointers
>To: FPC-Pascal users discussions <fpc-pascal at lists.freepascal.org>
>Message-ID: <20061019144430.8232.qmail at web35610.mail.mud.yahoo.com>
>Content-Type: text/plain; charset=iso-8859-1
>
>The C routines are inside a shared library?. Can you post the "C" code to call these routines?
>
>--- Armando Navarro V·zquez <qoajnv at usc.es> wrote:
>
>>
>> Dear members:
>> I am not familiar with Pascal, but I would like to call some C routines inside
>> the main Pascal program, is there any way, to pass function pointers from
>> Pascal to the C subroutines?
>> Thanks in Advance
>> Armando
>> --
>> Dr. Armando Navarro-V·zquez
>> RIAIDT. Univdade de Resonancia Magnetica
>> Universidade de Santiago de Compostela
>> http://desoft03.usc.es/armando/index.html
>> _______________________________________________
>> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
>> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>>
>
>
>Leonardo M. RamÈ
>http://leonardorame.blogspot.com
>
>__________________________________________________




More information about the fpc-pascal mailing list