wuwuxin 28 Posted April 23, 2021 (edited) TMyFunkyRecord = record end; function MyFunkyFunction(AData: ^TMyFUnkyRecord): ^TMyFunkyRecord; Delphi gives me error saying : E2029 Identifier expected but '^' found I know I can define PMyFunkyRecord = ^TMyFunkyRecord; But Is the above code using pointer directly illegal? Edited April 23, 2021 by wuwuxin Share this post Link to post
David Heffernan 2345 Posted April 23, 2021 56 minutes ago, wuwuxin said: But Is the above code using pointer directly illegal? Yes. You have to declare a pointer type. Share this post Link to post
Mark- 29 Posted April 23, 2021 type TMyFunkyRecord = record b:boolean; end; function Something(inB:pointer):pointer; var bRec:TMyFunkyRecord; begin bRec:=TMyFunkyRecord(inB^); if bRec.b then beep; bRec.b:=false; result:=@bRec; end; var bRec,aRec:TMyFunkyRecord; begin bRec.b:=true; aRec:=TMyFunkyRecord(Something(@bRec)^); if not aRec.b then beep; end; You can make it work with "naked" pointers. More trouble than worth to avoid declaring the pointer type. My2c. Share this post Link to post
julkas 12 Posted April 24, 2021 (edited) For parameters you can use const or var qualifiers (option - declare absolute). For return - use generic pointer. See - Parameters Pascal is a strongly typed. :-). https://ideone.com/5r1Uqf Edited April 24, 2021 by julkas Share this post Link to post