New Tag Params
When I try to compile some of my Sources for MorphOS or Amiga I always stumble over the problem that this two platforms does not have the VarArgs version of all the function I use (mostly happen for SetAttr or CallHook). Besides the array of const Version we use now in AROS has some problems, especially with Shortstrings which gets copied to a string then conversed to PChar, but after the call already destroyed, can have bad behaviour.
Especially at MUI I noticed the most functions expect the strings to stay after call, so I long time decided already to change the calling to an array of NativeUInt which should be much better, because you are forced to think about strings/PChar casting and it should be easier to transfer things to Amiga/MorphOS.
I wrote a little helper routine for tag and parameter handling and tried to get rid of the units tagarray and longarray which are basically just broken. I decided to use the Advanced Record approach and it looked really good, in some test programs I did with operator overloading its really easy to use.
But in LCL it did not work at all. Very strange and bad problems everywhere, crashes always at different points. For one test the crash point was easy to identify by the callstack in a very short routine, so I started to debug there. But strange everything was right, IT SHOULD WORK! But it doesn’t I took out some of the commands just let Tagsarray empty… and it still crashes, all Pointers are correct but if you try to investigate the Tagsarray it crashes, really strange. Just for fun I changed the type of my tagsarray from a advanced record to an old school pascal object (not class) and voila it is working :-O seems the advanced records are barely broken on extensive use. I hope the object are working better.
4 comments to "New Tag Params"
That’s strange that things do not work as expected under lazarus. I was unable to find out so far. Did you explicitly defined to use advanced records ?
There are some differences regarding delphi mode and advanced records mode in usage with FPC.
FPC’s (default) advanced records are not 100% delphi compatible and have subtle differences. I didn’t notice any changes for this topic last couple of months so am therefor assuming this is still true.
I tried both, (mode Delphi and mode Objfpc + AdvancedRecords) both with the same result. I did some test programs before with it and it worked without any problems, so I thought its ok. You can check for yourself
The only thing i can think of atm is that explicit typecasting could screw things up. Unfortunately the object implementation does not has any explicit operators defined, so i currently can not check if that is/was causing the problem (at least not doing so easily).
While investigating i noticed some other things i wondered about. I’ll contact by mail for that.
Please ignore the latter remark.
I was looking at rather old source-code which made me wonder. It has been ‚fixed‘ in newer code 🙂