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:
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® X IDE, would still interpret the remaining CR as a new line but the compiler will not. Since it is legal to have two statements on the one line, seeing a multi-statement line is not flagged as an error, but if there is an error later in the code, the line number count will not be accurate.
To see the characters used by a source file you will need to use a text editor that can display them or dump the file in binary.
Microchip Technology acquires Atmel