Recent

Author Topic: Procedural Variables from delphi  (Read 5972 times)

PaulAtreides62

  • New Member
  • *
  • Posts: 19
Procedural Variables from delphi
« on: February 06, 2009, 01:46:56 pm »
My code is part of a windows 32bit library, realized , compiled end built under delphi ( 4, 5, ecc..) without errors.

I want to port it under lazarus ( 0.9.26 ) for windows 32bit.

Here my code, where i suppressed the other not important lines:

Code: [Select]
library Libreria;

{$mode objfpc}{$H+}

uses
 Windows,
 Messages,
 SysUtils,
 Classes,

(*
Graphics,
Controls,
Forms,
StdCtrls,
*)
Dialogs;
...

TYPE   TAzione = PROCEDURE( Action : PChar );
...

VAR    var_azione : TAzione; 
...

PROCEDURE Pippo( Puntatore : POINTER );
BEGIN
 var_azione := @TAzione( Puntatore );                <<<<<   ERROR
END;
...

EXPORTS Pippo;
...


The compilation error , into Pippo PROCEDURE, is
Code: [Select]
Libreria.lpr(175,23) Error: Incompatible types: got "Pointer" expected "<procedure variable type of procedure(PChar);Register>"

can you help me?  :'(



theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1927
Re: Procedural Variables from delphi
« Reply #1 on: February 06, 2009, 02:53:48 pm »
Have you tried many things before posting? ;-)

This should work:

PROCEDURE Pippo( Puntatore : POINTER );
BEGIN
 var_azione := TAzione( Puntatore );
END; 

or put {$mode delphi} instead of {$mode objfpc} in the source.

PaulAtreides62

  • New Member
  • *
  • Posts: 19
Re: Procedural Variables from delphi
« Reply #2 on: February 06, 2009, 06:24:27 pm »
I have tried both solutions, so that compiling and building is ok, but when when i use it calling a funtion ( it's a plug-in of other software ) , i obtain an access violation error:
Code: [Select]
Access violation at adress xxxx.. in module Libreria.dll . Read of address 0000000
:'( :'(
thank you at all

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Procedural Variables from delphi
« Reply #3 on: February 06, 2009, 06:36:59 pm »
It looks like you're putting a form in a library (DLL). That's a know problem with the win32 version of Lazarus. I've been successful at putting very large form-based apps in a library on OS X, but they crash on Windows with Lazarus and work fine with Delphi.

Can you continue using Delphi on Windows and use Lazarus for other platforms until this is fixed?

Look in the bug tracker for discussion of this issue.

Thanks.

-Phil

PaulAtreides62

  • New Member
  • *
  • Posts: 19
Re: Procedural Variables from delphi
« Reply #4 on: February 06, 2009, 09:23:13 pm »
Quote
It looks like you're putting a form in a library (DLL). That's a know problem with the win32 version of Lazarus.
It is so, Phil.
Quote
Can you continue using Delphi on Windows and use Lazarus for other platforms until this is fixed?
Yes, but when you foresee that it will happen?
thanks  :D

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Procedural Variables from delphi
« Reply #5 on: February 06, 2009, 09:36:56 pm »
There's a bounty now for fixing this bug (7182):

http://wiki.lazarus.freepascal.org/Bounties#Windows_bounties

Maybe you could add some $ to Oleg's bounty and thus increase the attractiveness of this to a potential fixer.

Thanks.

-Phil

 

TinyPortal © 2005-2018