List Info

Thread: (




(
user name
2006-05-24 09:49:11
----- Original Message -----
From: "Rob Kennedy&quot; <rkennedycs.wisc.edu>
To: <delphi-en@yahoogroups.com>;
Sent: Tuesday, May 23, 2006 5:06 PM
Subject: Re: [delphi-en] Re: :(


&gt; Mauro Russo wrote:
&gt; > can someone explain me why i'm not able to pass to a function a
> > pointer of object using the ''? What is amazing for me is that i could
do
> > it
> > whitout '' (really i didn't try yet if it doesn't get exception at run
> > time).
&gt; > The code is:
> >
> > type TVProc = Procedure(a: integer) cdecl stdcall;
>
> The calling convention of that function-pointer type is stdcall. The
> cdecl part is ignored. Is that what you intended?

Well, thanks. That explains something i had doubts about.

> > type TVMethod2 = Procedure(a: integer;b: integer) of object;
&gt;
> The calling convention for that method-pointer type is register, which
>; is not compatible with stdcall or cdecl.
&gt;
> > procedure MyProc2Test(a : integer;b : integer);
> > begin
>; > end;

sorry, here i forgot to report the "stdcall", but i have it in my code,
so it is compatible with TVProc.

> That is a two-argument function, which will not be compatible with
> TVProc or TVMethod2.
>
>; > procedure TForm1.MyMethod2Test(a : integer;b : integer);
> > begin
>; > end;
> >
> > TEcovDLL.Create(MyProc2Test,MyMethod2Test);
>; >
> > where:
&gt; >
> > type TEcovDLL = class
>; >   ; private
&gt; >   ; &nbsp; &nbsp; &nbsp; &nbsp;  ...
> >   ; public
&gt; >   ; &nbsp;  constructor
> >   ; &nbsp; &nbsp; &nbsp; Create(
&gt; >   ; &nbsp; &nbsp; &nbsp; &nbsp;  _Proc2_JustStartedAtmel : TVProc2;
> >   ; &nbsp; &nbsp; &nbsp; &nbsp;  _Method2_JustStartedAtmel : TVMethod2);overload;
>
> What other constructors does this class have?

constructor Create();overload;

> > end;
> >
> > and the call is
> > ...
> > var ObjEcov : TEcovDLL;
> > ...
> >   ; &nbsp;  ObjEcov := TEcovDLL.Create(MyProc2Test,MyMethod2Test); //compile
>
> You shouldn't need the "" operator for either of them.

Hm, i found the 'typed ' options disabled agina and after i enabled, you
are right.
I needn't the first ''
.
>  ;  ObjEcov := TEcovDLL.Create(MyProc2Test,MyMethod2Test); //doesn't
> > compile
&gt;
> "Doesn't compile&quot; is not an adequate description. What specific compiler
> message do you get?

The message is just
&quot;There is no overloaded versione of 'Create' that can be called with these
arguments";.

> > If i write an other version of the constructor Create (class TEcovDLL),
> > declaring as 'overloaded'
> > both constructors, i'm not able anymore to call the first constructor
with
&gt; > two parameters 'nil', but
> > i need to specify the pointer to object. What can be the cause?
&gt;
> That's a little hard to tell since you haven't shown both constructors.
> My guess is that when you specify nil for both parameters, the compiler
> can't decide which overloaded version to call. Nil is a valid value for
> all procedure-pointer and method-pointer types.

constructor Create();overload;

> --
> Rob

I hoped you can reproduce the problem on your PC.

Best Regards,
Mauro Russo.

>
>
> -----------------------------------------------------
> Home page: http://groups.yahoo.com/group/delphi-en/
> To unsubscribe: delphi-en-unsubscribe@yahoogroups.com
> Yahoo! Groups Links
>;
>
&gt;
>
&gt;
>
>

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )