Mauro Russo wrote:
> 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).
> 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?

> type TVMethod2 = Procedure(a: integer;b: integer) of object;

The calling convention for that method-pointer type is register, which
is not compatible with stdcall or cdecl.

> procedure MyProc2Test(a : integer;b : integer);
> begin
> end;

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:
>
> type TEcovDLL = class
>    private
>             ...
>    public
>       constructor
>          Create(
>             _Proc2_JustStartedAtmel : TVProc2;
>             _Method2_JustStartedAtmel : TVMethod2);overload;

What other constructors does this class have?

> end;
>
> and the call is
> ...
> var ObjEcov : TEcovDLL;
> ...
>       ObjEcov := TEcovDLL.Create(@MyProc2Test,MyMethod2Test); //compile

You shouldn't need the "@" operator for either of them.

>     ObjEcov := TEcovDLL.Create(@MyProc2Test,@MyMethod2Test); //doesn't
> compile

"Doesn't compile" is not an adequate description. What specific compiler
message do you get?

> 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
> two parameters 'nil', but
> i need to specify the pointer to object. What can be the cause?

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.

--
Rob


-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]




YAHOO! GROUPS LINKS




Reply via email to