Microchip Technology XC8 Standard Compiler (Workstation) SW006021-1 SW006021-1 User Manual

Product codes
SW006021-1
Page of 518
MPLAB
®
 XC8 C Compiler User’s Guide
DS52053B-page 72
 2012 Microchip Technology Inc.
4.2
INVOKING THE COMPILER
This section explain how to invoke xc8 on the command line, as well as the files that it 
can read.
4.2.1
Driver Command-line Format
xc8
 has the following basic command format.
xc8 [optionsfiles [libraries]
Throughout this manual, it is assumed that the compiler applications are in the con-
sole’s search path or that the full path is specified when executing an application. The 
compiler’s location can be added to the search path when installing the compiler by 
selecting the Add to environment checkbox at the appropriate time during the 
installation.
It is customary to declare options (identified by a leading dash “-” or double dash “–”) 
before the files’ names. However, this is not mandatory.
The formats of the options are supplied in Section 4.7 “XC8 Driver Options”, along 
with corresponding descriptions of the options.
The files may be an assortment of C and assembler source files, and precompiled 
intermediate files, such as relocatable object (.obj) files or p-code (.p1) files. While 
the order in which the files are listed is not important, it may affect the order in which 
code or data appears in memory, and may affect the name of some of the output files.
Libraries
 is a list of user-defined object code or p-code library files that will be 
searched by the code generator (in the case of p-code libraries) or the linker (for object 
code libraries), in addition to the standard C libraries. The order of these files will deter-
mine the order in which they are searched. It is customary to insert the Libraries list 
after the list of source file names. However, this is not mandatory.
If you are building code using a make system, familiarity with the unique intermediate 
p-code file format as described in Section 4.3.3 “Multi-Step Compilation” is recom-
mended. Object files are seldom used with the MPLAB XC8 C Compiler, unless 
assembly source modules are in the project.
4.2.1.1
LONG COMMAND LINES
The xc8 driver is capable of processing command lines exceeding any operating sys-
tem limitation if the driver is passed options via a command file. The command file is 
specified by the @ symbol, which should be immediately followed (i.e., no intermediate 
space character) by the name of the file containing the command-line arguments that 
are intended for the driver.
Each command-line argument must be separated by one or more spaces and may 
extended to several lines by using a space and backslash character to separate lines. 
The file may contain blank lines, which are simply skipped by the driver.
The use of a command file means that compiler options and source code filenames can 
be permanently stored for future reference without the complexity of creating a make 
utility.
In the following example, a command file xyz.cmd was constructed in a text editor and 
contains both the options and file names that are required to compile a project.
--chip=16F877A -m \
--opt=all -g \
main.c isr.c
After it is saved, the compiler may be invoked with the following command:
xc8 @xyz.cmd