Re: [firebird-support] Creating UDF - stdcall vs cdeclAnd if you want to return string values, make sure to use IBAlloc instead of GetMem or other Delphi functions to allocate memory.
With regards, Martijn Tonies Upscene Productions http://www.upscene.com Download Database Workbench for Oracle, MS SQL Server, Sybase SQL Anywhere, MySQL, InterBase, NexusDB and Firebird! From: mailto:[email protected] Sent: Tuesday, October 07, 2014 2:52 PM To: mailto:[email protected] Subject: Re: [firebird-support] Creating UDF - stdcall vs cdecl The link you pointed has incorrect information. When using Delphi, UDF functions should use cdecl not stdcall. Delphi/Pascal gives you the necessary syntax and functions to work with pointers, so just get used to them <g> []s Carlos Firebird Performance in Detail - http://videos.firebirddevelopersday.com www.firebirdnews.org - www.FireBase.com.br Hi everyone, I am studying how to create UDFs on Firebird, but there is a thing that I can not understand. Samples that I found over internet, like this: http://www.firebirdsql.org/en/writing-udfs-in-delphi-for-interbase-firebird/ All functions are exported as stdcall: function Teste(sVar:PAnsiChar; iVar:Integer):PAnsiChar; stdcall ; I dont use string, only pAnsiChar, Integer and Double. Ok, at this point, but when register inside Firebird and execute, the app (flamerobin or ibexpert) crash. Then, I change to export function DLL as cdecl and change Integer type to Integer as Pointer: type PInteger = ^Integer; function Teste(sVar:PAnsiChar; iVar:PInteger):PAnsiChar; cdecl; runs fine, but I have very difficult to handle with pointers (hello pascal). I can“t make a simple 'hello word' using stdcall functions. Even copy samples over internet. I use Delphi XE5 and FB 2.5.3. I would like to know if is possible to work writting UDFs as stdcall or I have to adapter with cdecl and pointers to make my own UDFs. Thx,
