2
votes

I'm wondering why if the compiler directives was typed on multi lines will effects the selected IDE error line.

For example:

{$SETPEFlAGS IMAGE_FILE_DEBUG_STRIPPED or
 IMAGE_FILE_LINE_NUMS_STRIPPED or
 IMAGE_FILE_LOCAL_SYMS_STRIPPED or
 IMAGE_FILE_RELOCS_STRIPPED}

.....

procedure Foo();
begin
  WriteLn('1');
  WWriteLn('2');
  WriteLn('3');
  WriteLn('4');
  WriteLn('5');
end; 

IDE Error

[dcc32 Error] Crypter.dpr(29): E2003 Undeclared identifier: 'WWriteLn'

Inside the source code the selected line is WriteLn('5'); not WWriteLn('2');

But if the compiler directives was typed on this way (one line) :

{$SETPEFlAGS IMAGE_FILE_DEBUG_STRIPPED or IMAGE_FILE_LINE_NUMS_STRIPPED or IMAGE_FILE_LOCAL_SYMS_STRIPPED or IMAGE_FILE_RELOCS_STRIPPED}

Will fix the issue!.

1

1 Answers

4
votes

If things are as you say, then this is a defect in the IDE. Report the issue as a bug to Quality Portal.

It's easy to work around the issue. Simply don't use multi-line directives. In this case you can extract the flag into a separate constant and refer to it in the directive.

const
  PEFlags = IMAGE_FILE_DEBUG_STRIPPED or
    IMAGE_FILE_LINE_NUMS_STRIPPED or
    IMAGE_FILE_LOCAL_SYMS_STRIPPED or
    IMAGE_FILE_RELOCS_STRIPPED;

{$SETPEFlAGS PEFlags}

The reason I hesitate in the first paragraph is that what you describe would also occur if the linefeeds were incorrect. If your linefeeds are not CR+LF then the IDE gets confused about line numbers. So, it's worth checking that your linefeeds are CR+LF. You could simply re-type the code and the linefeeds will be correct. Typically you get mixed up linefeeds when you paste from another source.