Address of function in typeless pointer constant lazarus / 62-General ---------------------------------------------------------------------- TCH · 2021-10-14 21:00 I have a small program:Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program x; function kecske(a: integer): integer; cdecl;begin      kecske := a + 8;end; var ptr: Pointer = Pointer(@kecske); beginend.fpc x.pasCode: [Select]x.pas(8,36) Error: Illegal expressionIf i change the var to const, the result is identical. How can i store a function's address to a constant or an initialized variable as an untyped pointer? ---------------------------------------------------------------------- howardpc · 2021-10-14 22:59 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program pointerEx; {$mode objfpc} function kecske(a: integer): integer; cdecl;begin  kecske := a + 8;end; var  pKecske: Pointer = @kecske; beginend.This compiles OK for me. ---------------------------------------------------------------------- TCH · 2021-10-15 08:09 Yeah, that worked for me too, but unfortunately it did not worked in my real case. My example program was incomplete. This was more like what i wanted to accomplish:Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program x; type        TProc = procedure; cdecl;        TKecske = function (a: integer): integer; cdecl;        PPointer = ^Pointer; var Func: TProc; function kecske(a: integer): integer; cdecl;begin        kecske := a + 8;end; const        pKecske: Pointer = @kecske;        pFunc: Pointer = @Func; procedure set_it1(src: Pointer; dst: PPointer);begin        dst^ := src;end; begin        set_it1(pKecske, @pFunc);        WriteLn(TKecske(pFunc)(8));end.But in the meantime, i figured it out, the catch was casting the pointer to ppointer. Thanks for helping. ---------------------------------------------------------------------- howardpc · 2021-10-15 10:11 I think it is generally better practice to use typed pointers, or if you have to use an untyped pointer cast it to the correct type: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program pointerEx; {$mode objfpc} type   TFunc = function(b: Integer): Integer; cdecl; function kecske(a: integer): integer; cdecl;begin  kecske := a + 8;end; var  pKecske: Pointer = @kecske; begin  WriteLn(TFunc(pKecske)(8);  ReadLn;end. ---------------------------------------------------------------------- TCH · 2021-10-15 10:25 I have to work with different type of procedures and functions and store their addresses in a common list, so i only can store them as untyped pointers; usage is done with casting of course.