7.6.1 Options Specific to 16-Bit Devices

For more information on the memory models, see section Memory Models.

Table 7-5. 16-Bit Device-Specific Options
OptionDefinition
-mcodecovThis option is used for MPLAB® Code Coverage support. Passing the option -mcodecov=near or -mcodecov=far to the compiler causes it to instrument the generated assembly-instruction blocks with information that the MPLAB X IDE can then use to perform a code coverage analysis. This feature requires MPLAB X IDE v5.25 or later. For more on this features, visit:

www.microchip.com/mplab/codecoverage

-mconst-in-codePut const qualified variables in the auto_psv space. The compiler will access these variables using the PSV window (This is the default).
-mconst-in-dataPut const qualified variables in the data memory space.
-mconst-in-
auxflashWhen combined with -mconst-in-code, put all const qualified file scope variables into auxiliary Flash. All modules with auxiliary Flash should be compiled with this option; otherwise a link error may occur.
-mcpu=
targetThis option selects the target processor ID (and communicates it to the assembler and linker if those tools are invoked). This option affects how some predefined constants are set; see section Predefined Macro Names for more information. A full list of accepted targets can be seen in the Readme.htm file that came with the release.
-mdfp=pathThis option directs the compiler to use the device support included in the specified device family pack (DFP). The directory should be to the 'xc16' folder within the pack. This option is usually used by MPLAB X IDE or MPLAB IPE when specifying a pack.
-mno-eds-warnOn some devices, there is a possibility that the stack will reside in EDS (extended data space) memory (above 0x8000), though this allocation is disabled by default in the linker. If the stack is located in this area, then taking the address of an auto variable would require an __eds__ pointer. As the compiler does not know where the stack will be located, the default is to be conservative and warn if the address of an auto is taken and not used as an __eds__ pointer. This option disables the warning.
-merrata=
id[,id]*This option enables specific errata workarounds identified by id. Valid values for id change from time to time and may not be required for a particular variant. An id of list will display the currently supported errata identifiers along with a brief description of the errata. An id of all will enable all currently supported errata workarounds.
-mno-errata=
id[,id]*This option disables specific errata workarounds identified by id. Valid values for id change from time to time. This is particularly useful when specifying errata with -merrata=all as it can be used to disable some errata that are not required. -mno-errata=foo will prevent the erratum foo from being enabled no matter where it appears on the command line. Therefore, -mno-errata=foo -merrata=foo will not enable erratum foo.
-mno-fileDo not emit a .file directive in the generated assembly file. This is useful when creating libraries where the source code may not reside on the end-user's machine, as this will prevent the IDE from trying to load the source file during a debug session.
-mfillupperSpecify the upper byte of variables stored into space(prog) sections. The fillupper attribute will perform the same function on individual variables.
-mlarge-arraysSpecifies that arrays may be greater than or equal to the default maximum size of 32K. See Non-Auto Variable Allocation and Access, Non-Auto Variable Size Limits for more information.
-mlarge-codeCompile using the large code model. No assumptions are made about the locality of called functions.

When this option is chosen, single functions that are larger than 32k are not supported and may cause assembly-time errors since all branches inside of a function are of the short form.

-mlarge-dataCompile using the large data model. No assumptions are made about the location of static and external variables.
-mlegacy-libcMPLAB XC16 (originally MPLAB C30) has a long history. This option allows us to support previously deployed C libraries as needed (This is the default).
-moptimize-page
-settingAttempt to reduce the number page switches when using memory modes that affect the PSVPAG. This is really an optimization, and is not enabled by default. Like all optimizations it will generally have a positive effect on performance or code size.
-mpa1.Enable the procedure abstraction optimization. There is no limit on the nesting level.

Optimization levels depend on the compiler edition (see section Optimizations).

-mpa=n1.Enable the procedure abstraction optimization up to level n. If n is zero, the optimization is disabled. If n is 1, first level of abstraction is allowed; that is, instruction sequences in the source code may be abstracted into a subroutine. If n is 2, a second level of abstraction is allowed; that is, instructions that were put into a subroutine in the first level may be abstracted into a subroutine one level deeper. This pattern continues for larger values of n. The net effect is to limit the subroutine call nesting depth to a maximum of n.

Optimization levels depend on the compiler edition (see Optimizations).

-mno-pa1.Do not enable the procedure abstraction optimization (This is the default).
-mpreserve-allMake all variables in this translation unit preserved unless explicitly marked with the update attribute.
-mprint-
 builtinsDisplay the complete list of target builtin functions available in the compiler.
-mprint-devicesDisplay the complete list of real and virtual devices supported by the current installation.
-mprint-mchp-
 search-dirsA target-specific option to output the compiler and assembler include search paths to the console. These paths can change based upon various options.
-mno-isr-warnBy default the compiler will produce a warning if the __interrupt__ is not attached to a recognized interrupt vector name. This option will disable that feature.
-omfSelects the OMF (Object Module Format) to be used by the compiler. The omf specifier can be one of the following:

elf Produce ELF object files (This is the default).

coff Produce COFF object files.

The debugging format used for ELF object files is DWARF 2.0.

-msfr-warnBy default we warn when accessing SFRs for a generic device; use -mno-sfr-warn to disable this feature.
-msmall-codeCompile using the small code model. Called functions are assumed to be proximate (within 32 Kwords of the caller). (This is the default.)
-msmall-dataCompile using the small data model. All static and external variables are assumed to be located in the lower 8 KB of data memory space. (This is the default.)
-msmall-scalarLike -msmall-data, except that only static and external scalars are assumed to be in the lower 8 KB of data memory space. (This is the default.)
-msmart-io-
 format=fmtWhen using smart-io the compiler is not able to detect the format string when it is a variable. -msmart-io-format can be used to tell the compiler which format specifiers to expect in such a string. For example:

printf(stderr,fmt,a,b,c);

can be compiled with -msmart-io-fmt=“%s%c%d” to define the default format and smart-io will generate code to match this set of format specifiers when it cannot determine the correct format specifiers at runtime.

-mtext=nameSpecifying -mtext=name will cause text (program code) to be placed in a section named name rather than the default .text section. No white spaces should appear around the =.
-mauxflashPlace all code from the current translation unit into auxiliary Flash. This option is only available on devices that have auxiliary Flash.
-msmart-io [=0|1|2]This option attempts to statically analyze format strings passed to printf, scanf and the ‘f’ and ‘v’ variations of these functions. Uses of nonfloating point format arguments will be converted to use an integer-only variation of the library functions.

-msmart-io=0 disables this option, while -msmart-io=2 causes the compiler to be optimistic and convert function calls with variable or unknown format arguments. -msmart-io=1 is the default and will only convert the literal values it can prove.

--partition nThis option targets a single partition n in a dual partition device and will constrain the output text to be contained within one panel.
Note 1: The procedure abstractor behaves as the inverse of inlining functions. The pass is designed to extract common code sequences from multiple sites throughout a translation unit and place them into a common area of code. Although this option generally does not improve the run-time performance of the generated code, it can reduce the code size significantly. Programs compiled with -mpa can be harder to debug; it is not recommended that this option be used while debugging using the COFF object format.
The procedure abstractor is invoked as a separate phase of compilation, after the production of an assembly file. This phase does not optimize across translation units. When the procedure-optimizing phase is enabled, inline assembly code must be limited to valid machine instructions. Invalid machine instructions or instruction sequences, or assembler directives (sectioning directives, macros, include files, etc.), must not be used, or the procedure abstraction phase will fail, inhibiting the creation of an output file.