Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Why don the line numbers in an error message match the actual line with the problem?

0
Posted

Why don the line numbers in an error message match the actual line with the problem?

0

In many cases an error or warning is reported for a line that follows the line that contains the error. For example, consider these lines; the first is missing a semi-colon at the end: input = read() input += offset; There will an expression error produced, but the error will indicate the second line. This is reasonable as the C language allows statements to be spread over multiple lines, so there is nothing actually wrong with the first line of code. Once the second line is parsed, it then becomes obvious that something is wrong. The error will be flagged at the line at which things first go wrong. If you are seeing error messages that are out by a number of lines, one thing you can check is that your source files are using the correct “new line” characters. If you are compiling under Windows, there should be CR-LF sequence at the end of each line. If, for example the LF character was stripped somehow from a line, IDEs, like MPLAB, would still interpret the remaining CR as a new line

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123