4.1.3 Input File Types
The xc8-cc
driver distinguishes source
files, intermediate files and library files solely by the file type or extension. The
following case-sensitive extensions, listed in Table 3-1 are recognized.
Extension | File format |
---|---|
.c |
C source file |
.i |
Preprocessed C source file |
.p1 |
P-code intermediate file |
.s |
Assembler source file |
.S |
Assembly source file requiring preprocessing |
.as or .asm |
Assembly source file |
.o |
Relocatable object code file |
.a |
Archive (library) file |
.hex |
Intel HEX file |
There are no compiler restrictions imposed on the base names of source files, but be aware of case, name-length, and other restrictions that are imposed by your host operating system.
Avoid using the same base name for assembly and C source files, even if they are located in different directories. For example, if a project contains a C source file called init.c, do not also add to the project an assembly source file with the name init.s. Avoid also having source files with the same base name as the name of the IDE project that contains them.
MPLAB XC8
will accept assembly source files with the .as or
.asm extensions, but these extensions are not accepted by other XC
compilers. It is recommended that you use the .s extension for
assembly source files. Alternatively, you can use the .S extension or
use the -x
option with source files using a .s
extension
for assembly source files that must be preprocessed before being assembled.
The terms source file and module are often used interchangeably, but they refer to the source code at different points in the compilation sequence.
A source file is a file that contains all or part of a program. It may contain C code, as well as preprocessor directives and commands. Source files are initially passed to the preprocessor by the compiler driver.
A module is the output of the preprocessor for a given source file, after the inclusion of
any header files specified by#include
preprocessor directives and after
the processing and subsequent removal of other preprocessor directives (with the possible
exception of some commands for debugging). Thus, a module is usually the amalgamation of a
source file and several header files, and it is this output that is passed to the remainder
of the compiler applications. A module is also referred to as a translation
unit.
These terms can also be applied to assembly source files, which can be preprocessed and
include other (.inc
) files to produce an assembly module.