Microchip Technology SW006022-2N Data Sheet
MPLAB
®
XC16 C Compiler User’s Guide
DS52071B-page 56
2012 Microchip Technology Inc.
For example, the files ex1.c and add.c are to be compiled using a make utility. The
command lines that the make utility should use to compile these files might be some-
thing like:
command lines that the make utility should use to compile these files might be some-
thing like:
xc16-gcc -mcpu=30f6014 -c ex1.c
xc16-gcc -mcpu=30f6014 -c add.c
xc16-gcc -mcpu=30f6014 -o ex1 ex1.o add.o
The -c option will compile the named file into the intermediate (object) file format, but
not link. Once all files are compiled as specified by the make, then the resultant object
files are linked in the final step to create the final output ex1. The above example uses
the command-line driver, xc16-gcc, to perform the final link step. You can explicitly
call the linker application, xc16-ld, but this is not recommended. When driving the linker
application, you must specify linker options, not driver options. For more on using the
linker, see MPLAB Assembler, Linker and Utilities for PIC24 MCUs and dsPIC DSCs
User’s Guide (DS51317).
not link. Once all files are compiled as specified by the make, then the resultant object
files are linked in the final step to create the final output ex1. The above example uses
the command-line driver, xc16-gcc, to perform the final link step. You can explicitly
call the linker application, xc16-ld, but this is not recommended. When driving the linker
application, you must specify linker options, not driver options. For more on using the
linker, see MPLAB Assembler, Linker and Utilities for PIC24 MCUs and dsPIC DSCs
User’s Guide (DS51317).
When compiling debug code, the object module format (OMF) must be consistent for
compilation, assembly and linking. The ELF/DWARF format is used by default but the
COFF format may also be selected using -omf=coff or the environmental variable
XC16_OMF
compilation, assembly and linking. The ELF/DWARF format is used by default but the
COFF format may also be selected using -omf=coff or the environmental variable
XC16_OMF
.
3.3.4
Assembly Compilation
A mix of C and assembly code can be compiled together using the compiler
(Figure 3-1). For more details, see Chapter 13. “Mixing C and Assembly Code”.
(Figure 3-1). For more details, see Chapter 13. “Mixing C and Assembly Code”.
Additionally, the compiler may be used to generate assembly code (.s) from C code
(.c) using the -S option. The assembly output may then be used in subsequent com-
pilation using the command-line driver.
(.c) using the -S option. The assembly output may then be used in subsequent com-
pilation using the command-line driver.