Nested procvars are a separate type of proc/methods vars.
So you have normal procedures variables for global functions, procedure "of object" for methods, and "is nested" for nested functions.
Nested functions are a bit like method vars, in that the procvars are two pointers and have limited validity.
- method vars contain code: function address and data :self, and validity till the object is freed.
- nested procvar contain code: function address and data: framepointer, and validity till the outer procedure is finished and the framepointer is thus no longer valid
In short, it is is a fairly pascal specific feature, and I doubt it will be of use in windows interfacing. I suspect you are accidentally trying to passa nested function to something expecting a global function, and you are not in {$mode delphi}
Try Casting around your address of your callback...Thank you Jamie, that works. I don't see why I have to cast it but, for now, I'll take it. I'm sure that's going to bite me later but, at least for now, I can move forward.
HOCKRPOC(@YourcallBack)
The thing is, the function is not a method, and is not nested. It's just a plain vanilla function.
...
There must be something in the code that is confusing FPC. It will be interesting to find out what it is.
I know but, the unit is almost 6000 lines and in the middle of being edited for porting.The thing is, the function is not a method, and is not nested. It's just a plain vanilla function.
...
There must be something in the code that is confusing FPC. It will be interesting to find out what it is.
Kind of hard to judge that when you did not show the full code.
in the midst of conditional directives and definitions, there was an unmatched brace. It didn't bother Delphi
Delphi allows you to take the address of a nested function, such as for use as an API callback, but it is not safe/recommended to do so because of the tricks the compiler has to play with the stack frames to allow nested functions to access local variables of outer frames. I guess FreePascal is more restrictive about using the address of nested functions in function pointers.What happened is that, because Delphi and FPC don't treat nested comments the same way (using braces), Delphi was seeing the code as I meant it to be. For FPC it resulted in a "lone" function header which gobbled up the entire rest of the unit. I didn't realize that until I had corrected all the other things that Delphi was ok with but FPC objected to.
And you can do the same in FPC because you can switch them off (default in $mode delphi)
This is the second time a misplaced brace gives me a headache. Never noticed them before because Delphi doesn't do nested comments.
one directive I would gladly use is {$thaddy off} but it's not documented and, I'm pretty sure it wouldn't work anyway.And you can do the same in FPC because you can switch them off (default in $mode delphi)
This is the second time a misplaced brace gives me a headache. Never noticed them before because Delphi doesn't do nested comments.
Some people never read documentation....
one directive I would gladly use is {$thaddy off}I would be proud of that! When I am dead... Still you'd be better off to actually read the documentation. Which is excellent. Which you refuse to do.... Which in turn is completely silly.