Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi - How to use more defined values in conditional compilation

Can I combine some IFDEFS in my source?

For example:

{$IFDEF INCOMING or OUTGOING}
...
{$ENDIF}

Thanks for your help: dd

like image 281
durumdara Avatar asked Jul 22 '11 12:07

durumdara


4 Answers

Here's a variation of David's answer using 'not'.

I use this when I want to disable the splash screen on my apps while in debug mode. It prevents me from accidentally leaving the splash disabled if I forget to undefine NOSPLASH in the release build.

  {$IF not (Defined(NOSPLASH) AND Defined(DEBUG))}
     //code to create splash 
  {$IFEND} 
like image 108
TheSteven Avatar answered Nov 13 '22 00:11

TheSteven


Use $IF with Defined() rather than $IFDEF:

{$IF Defined(INCOMING) or Defined(OUTGOING)}
...
{$IFEND}
like image 37
David Heffernan Avatar answered Nov 13 '22 02:11

David Heffernan


Alternative, for older versions:

{$IFDEF INCOMING}
  {$DEFINE INCOMING_OR_OUTGOING}
{$ENDIF}
{$IFDEF OUTGOING}
  {$DEFINE INCOMING_OR_OUTGOING}
{$ENDIF}

{$IFDEF INCOMING_OR_OUTGOING}
...
{$ENDIF}
like image 14
Ondrej Kelle Avatar answered Nov 13 '22 01:11

Ondrej Kelle


I don't believe the $IFDEF supports it, but the $IF does. http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/devcommon/compdirsifdirective_xml.html

like image 3
hatchet - done with SOverflow Avatar answered Nov 13 '22 00:11

hatchet - done with SOverflow