Subject Re: [firebird-support] Creating UDF - stdcall vs cdecl
Author Martijn Tonies (Upscene Productions)
Re: [firebird-support] Creating UDF - stdcall vs cdecl
And 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

Download Database Workbench for Oracle, MS SQL Server, Sybase SQL
Anywhere, MySQL, InterBase, NexusDB and Firebird!
Sent: Tuesday, October 07, 2014 2:52 PM
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>

Firebird Performance in Detail - -

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:

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.