开发者

Delphi - How to use more defined values in conditional compilation

开发者 https://www.devze.com 2023-03-22 11:05 出处:网络
Can I combine some IFDEFS in my source? For example: {$IFDEF INCOMING or OUTGOING开发者_如何学Python}

Can I combine some IFDEFS in my source?

For example:

{$IFDEF INCOMING or OUTGOING开发者_如何学Python}
...
{$ENDIF}

Thanks for your help: dd


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

{$IF Defined(INCOMING) or Defined(OUTGOING)}
...
{$IFEND}


Alternative, for older versions:

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

{$IFDEF INCOMING_OR_OUTGOING}
...
{$ENDIF}


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


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} 
0

精彩评论

暂无评论...
验证码 换一张
取 消