| View previous topic :: View next topic |
| Author |
Message |
William Egge Guest
|
Posted: Wed Dec 27, 2006 7:18 pm Post subject: Getting pointer to overloaded procedure |
|
|
Can anyone tell me a way I can get a pointer to an overloaded procedure or
function?
For instance:
procedure Test(S: string); overload;
procedure Test(I: Integer); overload;
..
..
..
var
PToStr, PToInt: Pointer;
PToStr:= @Test; // ??
PToInt:= @Test; // ?? |
|
| Back to top |
|
 |
Pieter Zijlstra Guest
|
Posted: Wed Dec 27, 2006 9:17 pm Post subject: Re: Getting pointer to overloaded procedure |
|
|
William Egge wrote:
| Quote: | Can anyone tell me a way I can get a pointer to an overloaded
procedure or function?
For instance:
procedure Test(S: string); overload;
procedure Test(I: Integer); overload;
var
PToStr, PToInt: Pointer;
|
By using typed procedure pointers...
type
PProcS = procedure(S: string);
PProcI = procedure(I: Integer);
var
PToStr: PProcS;
PToInt: PProcI;
begin
PToStr := Test;
PToInt := Test;
--
Pieter |
|
| Back to top |
|
 |
William Egge Guest
|
Posted: Fri Dec 29, 2006 8:05 pm Post subject: Re: Getting pointer to overloaded procedure |
|
|
Thanks, do you know if there is a way without having to do that?
Like something that requires no setup? |
|
| Back to top |
|
 |
Pieter Zijlstra Guest
|
Posted: Fri Dec 29, 2006 10:52 pm Post subject: Re: Getting pointer to overloaded procedure |
|
|
William Egge wrote:
| Quote: | Thanks, do you know if there is a way without having to do that?
Like something that requires no setup?
|
Not that I know of, but maybe there is fancy asm trick which does the
job, you're in the right group for that
Basically you need a way to tell the compiler which overloaded
procedure it should use. If the compiler 'thinks' that one of them is
not used it will not generate code for it. I don't know any other way
then using using typed procedure pointers to do that.
--
Pieter |
|
| Back to top |
|
 |
|