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 |
other | A file to be passed to the linker |
There are no compiler restrictions imposed on the 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. So, 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 MPLAB X IDE project name.
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 or .S extension for assembly source files.
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.
Like assembly source files, these terms can also be applied to assembly files, which can be preprocessed and can include other header files.