Menu

#119 bad indentation with compiler directives

open
Formatting (69)
2
2005-11-08
2005-10-27
Anonymous
No

try to indent this :

function Get_MemoryInUse: Longint;
begin
{$IFDEF FPC}
Result:=Get_HeapStatus.CurrHeapUsed;
{$ELSE}
Result := GetHeapStatus.TotalAllocated;
{$ENDIF}
end;

is it not normal (i think) that
Result:=Get_HeapStatus.CurrHeapUsed;
is indented twice whereas
Result := GetHeapStatus.TotalAllocated;
gets indented just once.

They should be both indented either twice or once.

This is a small bug, but... a bug anyway

Discussion

  • Anthony Steele

    Anthony Steele - 2005-11-08
    • priority: 5 --> 2
     
  • Anthony Steele

    Anthony Steele - 2005-11-08

    Logged In: YES
    user_id=66544

    In the FormatSettins|pre-processor page, if "enable
    preprocessor parsing" is checked, only one of these code
    paths will be parsed, and only this path will be formatted
    and indented. The other need not even be valid Delphi code.

    If the option is not checked, then both will be parsed and
    both will be formatted. Which option best suits you depends
    on the circumstances.

    The checked option is to cover cases such as

    procedure Foo;
    begin

    {$IFDEF BAR}
    DoSomeThing();
    end;
    {$ELSE}
    DoSomeThingElse();
    end;
    {$ENDIF}

    Where parsing both code paths does not result in valid code.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.