Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi C Callback Routine --> Delphi Definition (https://www.delphipraxis.net/138765-c-callback-routine-delphi-definition.html)

soulies 17. Aug 2009 10:11


C Callback Routine --> Delphi Definition
 
Hi,

wie übersetze ich folgende C Routine (Callback)

Delphi-Quellcode:
typedef void (*EIB7OnDataAvailable)(EIB7_HANDLE eib, unsigned long cnt, void* data);
mein Versuch:

Delphi-Quellcode:
 procedure EIB7OnDataAvailable( eib:EIB7_HANDLE ; cnt:Longword ; data:??? );
Was bedeutet das '*' bei '*EIB7OnDataAvailable' und welchen DelphiTyp hat 'data' ?

cya

uligerhardt 17. Aug 2009 10:16

Re: C Callback Routine --> Delphi Definition
 
Zitat:

Zitat von soulies
Was bedeutet das '*' bei '*EIB7OnDataAvailable'

Der * ist das C-Symbol für Zeiger. Er bedeutet hier, dass EIB7OnDataAvailable ein Funktionszeigertyp ist.

Zitat:

Zitat von soulies
und welchen DelphiTyp hat 'data' ?

void* ist der untypisierte Zeiger in C. In Delphi heißt das Pointer.

HTH,
Uli.

ken_jones 17. Aug 2009 10:28

Re: C Callback Routine --> Delphi Definition
 
Das stand Unsinn..
[EDIT: Oben steht schon alles...]

himitsu 17. Aug 2009 10:31

Re: C Callback Routine --> Delphi Definition
 
und long ist übrigens ein LongInt (bzw. aktuell auch Integer, da 32-Bit-Anwendung) ... ulong = LongWord (Cardinal)

soulies 17. Aug 2009 10:38

Re: C Callback Routine --> Delphi Definition
 
demnach würde ich dann die Routine so übersetzen:

Delphi-Quellcode:
procedure EIB7OnDataAvailable( eib:EIB7_HANDLE ; cnt:Cardinal; data:Pointer);
Korrekt ?

cya

DeddyH 17. Aug 2009 10:41

Re: C Callback Routine --> Delphi Definition
 
Ich bin zwar kein Crack, aber wenn ich das richtig verstehe eher so:
Delphi-Quellcode:
type
  EIB7OnDataAvailable = procedure( eib:EIB7_HANDLE ; cnt:Cardinal; data:Pointer);

soulies 17. Aug 2009 10:44

Re: C Callback Routine --> Delphi Definition
 
OK,

Dank an alle .

cya


Alle Zeitangaben in WEZ +1. Es ist jetzt 13:01 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz