Delphi XE2 : Off by 7-20 lines in debugger and compiler error line numbers also off by the same amount

前端 未结 3 1812
醉酒成梦
醉酒成梦 2021-02-19 10:21

I am having a problem with a large Delphi codebase where I work where as a side effect of porting from Delphi 2007 to XE2, we now encounter the following strange, related issues

相关标签:
3条回答
  • 2021-02-19 11:12

    It definitely is connected to line endings as explained in previous posts. It is extremely hard to try to edit it away, since the Embarcadero editor tries to do magic of its own and preserves the line endings of the current section (or so it seems),

    Solution: Right click in the IDE editor window, select "Format Source" (Ctrl-D) and accept.

    This will fix all line endings and removes the problem (for me any way). As a by-product you will get correctly formatted source code :-)

    0 讨论(0)
  • 2021-02-19 11:13

    I've seen things like this before, and IME it's generally due to an compiler bug in counting line numbers. If you have nonstandard line breaks (not CRLF) at some points--which can happen--the IDE will do proper line breaks but the compiler doesn't count them as new lines, so everything afterwards gets thrown off by one.

    What I do when I encounter a file like this is open it in EditPad, convert all linebreaks to some other style (Unix or Mac style) and then convert all linebreaks to Windows style and save it. This ensures that every line in the file ends with CRLF, and after a rebuild the issue with the blue dots not lining up right goes away.

    0 讨论(0)
  • 2021-02-19 11:18

    This is a common problem caused by mismatched line termination characters. (Code with a missing CR or LF on the end of the line.) It can also be caused by having a .dcu that doesn't match the source file that's open in the editor.

    For the first, the easiest fix is to open the source file in a regular text editor (such as Notepad). Make a small change (insert a blank line and then delete it), and save the file. Notepad will fix the line endings.

    If this isn't the issue, look for extra copies of the .dcu (or .pas) file that might be on your drive in the IDE's search path. Sometimes the compiler sees a different version than what's open in the editor.

    0 讨论(0)
提交回复
热议问题