<div dir="ltr">Hi everyone,<div><br></div><div>First of all, I am sorry if this is not the best place for this interoperability issue. </div><div><br></div><div>The problem I want to solve is how to make a Free Pascal binding for to the following piece of C code:</div><div><br></div><div>typedef struct _CCDBS { <br>  void *userdata; <br>  char buttons[256]; <br>  void *internal;<br>}CCDBS;<br><br>typedef int (ELCALLBACK *getExButtonStates)(CCDBS *);</div><div><br>#define EXTERNAL_DEV_NONE ((getExButtonStates)0)<br>#define EXTERNAL_DEV_CEDRUS ((getExButtonStates)1)<br>#define EXTERNAL_DEV_SYS_KEYBOARD ((getExButtonStates)2)<br></div><div><br></div><div>int ELCALLTYPE enable_external_calibration_device(getExButtonStates buttonStatesfcn, const char * config, void *userData);</div><div><br></div><div>Questions</div><div><br></div><div>(1) I have no idea on how to translate these god-casts, eg., ((getExButtonStates)0), to free pascal. Right now, I think that even if I don't really need them, I just want to understand and learn in the process.</div><div><br></div><div>(2) So, the whole point here is binding the "enable_external_calibration_device" function. It expects a "getExButtonStates buttonStatesfcn". Can you check if my current binding is right?</div><div><br></div><div>type<br><br>  PCCDBS = ^TCCDBS;<br>  TCCDBS = record<br>    userdata: Pointer;<br>    buttons: array[0..255] of Char;<br>    internal: Pointer;<br>  end;<br><br>  TGetExButtonStatesFunction = function (accdbs: PCCDBS): Int32; ELCALLTYPE<br><br>  function enable_external_calibration_device(<br>    buttonStatesfcn: TGetExButtonStatesFunction;<br>    config: PChar; userData: Pointer): Int32; ELCALLTYPE ELDLL<br></div><div><br></div><div>(3) I am using the ELCALLTYPE macro just because they were using them too, I am assuming backward compatibility. But I am not sure if I really need them. EyeLink code depends on custom SDL2 headers and I am running SDL2 Free Pascal related stuff just fine (and it has cdecl in everything). What do you think about that? For reference, this is the macro:</div><div><br></div><div>{$ifndef ELCALLTYPE}<br></div>  {$IFDEF Windows}<br>    {$DEFINE ELCALLTYPE := stdcall;}<br>  {$ELSEIF Linux}<br>    {$DEFINE ELCALLTYPE := cdecl;}<br>  {$ELSE}<br>    {$DEFINE ELCALLTYPE := cdecl;}<br>  {$ENDIF}<br><div>{$endif} </div><div><br></div><div>(4) I can send the code and soon will release it on my GitHub (cpicanco).</div><div><br></div><div>Best.</div><div>R</div><div><br></div><div>PS.: You can find a related discussion here <a href="https://stackoverflow.com/questions/76427311/free-pascal-bindings-for-a-typedef-function-inside-a-define-macro-and-a-number-o">https://stackoverflow.com/questions/76427311/free-pascal-bindings-for-a-typedef-function-inside-a-define-macro-and-a-number-o</a></div></div>