Incorrect line numbers on error shown in build log

When working with .ino files, the incorrect line number is shown when an error is encountered during the build process.

The same issue seems to be documented here: Build log referencing incorrect line

The problem seems to be that the build log is referencing the .cpp file generated as part of the process, and the solution in this instance was to just rename to .cpp. This breaks compatibility with the Arduino IDE, which I want to maintain, and also necessitates the creation of the relevant header file, so isn’t really a workable solution.

Is there any workaround for this? I can’t be the only person trying to work with .ino files!

Could you provide sketch to reproduce this issue?

I didn’t want to post my code, so I tried to reproduce the issue by leaving a semicolon out of blink.ino - but it gave the correct line number.

I then posted my code into the blink.ino sketch, and it too gave the correct line number!

I set about looking for every possible difference I could in the files within the project folder without success - then I noticed character encoding and line endings.

For anyone else that comes across this: Change your line endings from CRLF to LF! That’s all this issue was. I don’t know how I’ve managed to get this inconsistent across my projects, but I’m glad I’ve finally figured it out!

Thanks ivankravets :slight_smile:

1 Like

Thanks, I too have this problem. All I have to do is find out how to change line endings.

1 Like

On VSCode, you click on the highlighted bit on the status bar, and will get prompted for LF or CRLF EOL sequence… make you choice, save the file… done.

image

Thanks pfeerick,
I am using Atom, and after ages looking to change line ending in Platformio realised I needed to change it in Atom. I am not new to coding but I feel pretty dumb whilst getting to know a new editor.

I am now looking to convert old ending to new one!!!

Think I’ve found something though.

Regards

1 Like

Yeah… it can be daunting! :open_mouth: You can add basically the same functionality to Atom with the Line Ending Selector package.

1 Like