4.6.2 How Do I Find the Code that Caused Compiler Errors Or Warnings in My Program?
In most instances the message produced by the compiler indicates the offending line of code where the syntax error is relating to the source code. If you are compiling in MPLAB X IDE, you can double click the message and have the editor take you to the offending line. But identifying the offending code is not always so easy.
In some instances, the error is reported on the line of code following the line that needs attention. This is because a C statement is allowed to extend over multiple lines of the source file. It is possible that the compiler may not be able to determine that there is an error until it has started to scan the next statement. Consider the following code:
input = PORTB // oops - forgot the semicolon
if(input>6)
// ...
The missing semicolon on the assignment statement has been flagged on the
following line that contains the if()
statement.
In other cases, the error might come from the assembler, not the compiler. If the source being compiled is an assembly module, the error directly indicates the line of assembly code that triggered the error.
There are errors that do not relate to any particular line of code at all. An error in a compiler option or a linker error are examples of these.
If you need to see the assembly code generated by the compiler, look in the assembly list file. For information on where the linker attempted to position objects, see the map file. Consult the following document for information on the list and map files. It is available for download from the Microchip Technology website, www.microchip.com.
“MPLAB® XC-DSC Assembler, Linker and Utilities User’s Guide” (DS-50003590)