我需要四种条件编译,但其中有三种要使用同一段代码N1
N2
N3
N4
{$ifdef N1 or N2 or N3}
Code0
{$else}
Code4
{$endif}{$ifdef N1}
code1
{$endif}
{$ifdef N2}
code2
{$endif}{$ifdef N3}
code3
{$endif}怎么样能实现?

解决方案 »

  1.   

    设四个Bool变量Var N1,N2,N3,N4:Boolean;{$ifdef N1}
    N1:=True;
    {$endif}{$ifdef N2}
    N2:=True;
    {$endif}{$ifdef N3}
    N3:=True;
    {$endif}{$ifdef N4}
    N4:=True;
    {$endif}
    剩下的嘛……if N1 or N2 then
    begin
    ……
    end;if N3 or N4 then
    begin
    ……
    end;……
      

  2.   

    {$ifdef N1 or N2 or N3}
    Code0
    {$else}
    Code4
    {$endif}应该这样
    {$if defined(N1) or defined(N2) or defined(N3)}
    Code0
    {$else}
    Code4
    {$ifend}
      

  3.   

    定义一个N123
    {$ifdef N1}
    {$ifdef N2}
    {$ifdef N3}
    {$DEFINE N123}
    {$ifend}
    {$ifend}
    {$ifend}{$ifdef N123}
    code0
    ...............
      

  4.   

    搞错了,or的关系就这样啊:{$ifdef N4}
    Code4
    {$else}
    Code0
    {$endif}
      

  5.   

    怎么在{$message hint }中显示一个定义过的常量