Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   Delphi Compiler Direktive (https://www.delphipraxis.net/213998-delphi-compiler-direktive.html)

mwilms 4. Nov 2023 10:46

Delphi Compiler Direktive
 
Hallo,

Habe Frage zur bedingten Compilierung. Der folgende Code funktioniert nicht. Ich will "push rbx" anstelle von "push ebx" compilieren lassen, wenn "Windows 64" Modus aktiv ist. Zweite Frage ist {$DEFINE WIN64} überhaupt erforderlich oder ist das eine Compiler Variable?

{$DEFINE WIN64}
{$If WIN64}
push rbx
{$else}
push ebx
{$endif}

Vielen Dank

mwilms

Andreas13 4. Nov 2023 11:02

AW: Delphi Compiler Direktive
 
Hallo,

es müßte doch so heißen:
Delphi-Quellcode:
{$ifdef WIN64}
push rbx
{$else}
push ebx
{$endif}

FriedrichAT 4. Nov 2023 12:18

AW: Delphi Compiler Direktive
 
Hallo!
Hier für Debug bzw. Release / 32 od. 64

Delphi-Quellcode:
begin
  Application.Initialize;
  Application.MainFormOnTaskbar := True;
  Application.CreateForm(TForm1, Form1);

  {$IFDEF DEBUG}
    {$IFDEF WIN32}
    //Form1.Caption:= 'FM Hashtest Debug-X32';
    //Application.Title:= 'FM Hashtest Debug-X32';
    {$ENDIF WIN32}

    {$IFDEF WIN64}
     //Form1.Caption:= 'FM Hashtest Debug-X64';
     //Application.Title:= 'FM Hashtest Debug-X64';
     {$ENDIF WIN64}
  {$ENDIF DEBUG}

  {$IFDEF RELEASE}
    {$IFDEF WIN32}
    //Form1.Caption:= 'FM Hashtest - X32';
    //Application.Title:= 'FM Hashtest - X32';
    {$ENDIF WIN32}

    {$IFDEF WIN64}
    //Form1.Caption:= 'FM Hashtest - X64';
    //Application.Title:= 'FM Hashtest - X64';
    {$ENDIF WIN64}
  {$ENDIF RELEASE}


  Application.Run;
end.

himitsu 4. Nov 2023 13:23

AW: Delphi Compiler Direktive
 
Genau, da es ein DEFINE ist, muß es
Delphi-Quellcode:
{$IFDEF...} {$ENDIF}
heißen,

denn {$IF prüft eine Expression ("echte" Konstanten, sowie ein paar Compiler-Funktionen),
also
Delphi-Quellcode:
{$IF Defined(WIN64)} {$IFEND}
, oder

Delphi-Quellcode:
const
  aaa = 123;
  bbb = False;

{$IF aaa = 456}

{$IF (aaa = 123) and (CompilerVersion >= 21.0) and bbb}

mwilms 4. Nov 2023 14:12

AW: Delphi Compiler Direktive
 
Vielen Dank! Es funktioniert mit "ifdef". WIN64 muss außerdem nicht definiert werden.

mwilms


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:12 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