ich verstehe noch nicht genau, warum der Compiler einen Unterschied macht
wenn ich eine Funktion aus einer DLL "early" oder "late" einbinde.
Folgendes Beispiel:
Code: Alles auswählen
int Pa_GetVersion( void );
Code: Alles auswählen
function Pa_GetVersion(): cInt; cdecl; external LibName;
Code: Alles auswählen
Result:= 'PA version int: ' +IntToStr( Pa_GetVersion);
Für late binding ist das hier deklariert
Code: Alles auswählen
var Pa_GetVersion: function():cInt ; cdecl;
..
function Pa_Load( const libfilename:string):boolean;
..
Pointer( Pa_GetVersion):= DynLibs.GetProcedureAddress( PA_Handle, pAnsiChar( 'Pa_GetVersion'));
Und auch den Ergebnis-Typ der Funktion, denn der ist ja deklariert als cInt. Oder ?
Damit funktioniert das hier aber nicht ..
Code: Alles auswählen
Result:= 'PA version int: ' +IntToStr( Pa_GetVersion);
Error: Incompatible type for arg no. 1: Got "<procedure variable type of function:LongInt;CDecl>", expected "QWord"
sysstr.inc(861,10) Hint: Found declaration: IntToStr(QWord):AnsiString;
sysstr.inc(856,10) Hint: Found declaration: IntToStr(Int64):AnsiString;
sysstr.inc(850,10) Hint: Found declaration: IntToStr(LongInt):AnsiString;
Der Compiler ruft also IntToStr(QWord) auf statt IntToStr(LongInt) - und das geht natürlich nicht.
Eigentlich müßte der Compiler doch wissen daß function result von Pa_GetVersion = Typ cInt ist ??
Und daher IntToStr(LongInt) anwenden ?