6.6.3 xc16-gcc (16-bit C Compiler)

Although the MPLAB XC16 C Compiler works with MPLAB X IDE, it must be acquired separately. The full version may be purchased, or a student (limited-feature) version may be downloaded for free. See the Microchip website (www.microchip.com) for details.

A subset of command-line options may be specified in MPLAB X IDE. Select a category and then set up compiler options. For additional options, see the Driver Option Descriptions.

See also Options Page Features.

Table 6-4. General Category
OptionDescriptionCommand Line
Generate debugging infoCreate a COFF or ELF file with information to allow debugging of code in MPLAB X IDE.

Note: COFF supports debugging in the .text section only.

-g
Isolate each function in a sectionCheck to place each function into its own section in the output file. The name of the function determines the section’s name in the output file.

Note: When you specify this option, the assembler and linker may create larger object and executable files and will also be slower.

Uncheck to place multiple functions in a section.

-ffunction-sections
Place data into its own sectionPlace each data item into its own section in the output file.

The name of the data item determines the name of the section. When you specify this option, the assembler and linker may create larger object and executable files and will also be slower.

-fdata-sections
Use 64-bit doubleUse long double instead of double type equivalent to float. Mixing this option across modules can have unexpected results if modules share double data either directly through argument passage or indirectly through shared buffer space-fno-short-double
Fill upper value for data in flashFill upper flash memory with the value specified.-mfillupper=value
Name the text sectionPlace text (program code) in a section named name rather than the default .text section.-mtext=name
Table 6-5. Memory Model Category
OptionDescriptionCommand Line
Code modelSelect a code (program memory/ROM) model.

- default

- large (>32 K words)

- small (<32 K words)

-msmall-code

-mlarge-code

-msmall-code

Data modelSelect a data (data memory/RAM) model.

- default

- large (device dependent1)

- small (device dependent1)

device dependant2

-mlarge-data

-msmall-scalar

Scalar modelSelect a scalar model.

- default

- large (device dependent1)

- small (device dependent1)

-msmall-scalar

-mlarge-scalar

-msmall-scalar

Location of constant modelSelect a memory location for constants.

- default

- Data

- Code

-mconst-in-code

-mconst-in-data

-mconst-in-code

Place all code in auxiliary flash Place all code from the current translation unit into auxiliary Flash. This option is only available on devices that have auxiliary Flash.-mauxflash
Put constants into auxiliary flashWhen combined with -mconst-in-code, put constants into auxiliary Flash.-mconst-in-auxflash
Allow arrays larger than 32KAllow arrays that are larger than 32K, regardless of memory model.-menable-large-arrays
Aggregate data modelUse aggregate data model. -mlarge-aggregate
Note:
  1. For most devices 6K of RAM is the near data space, but for some devices it is 4K of RAM.
  2. For devices that have all of their data memory in the near space, the memory model is "small data" "smallscalar" so that all memory will be allocated in the near space.

    For all other devices the default memory model is "large data" "small scalar". This will have the effect ofallowing the tool chain to place aggregate objects, such as arrays and structure, into the far memory space. This can be over-ridden by explicitly selecting "small data" in the compiler options.

Table 6-6. OPTIMIZATION CATEGORY
OptionDescriptionCommand Line
Optimization LevelSelect an optimization level. Equivalent to -On option, where n is an option. See Options for Controlling Optimization.

Your compiler license may support only some optimizations. See Chapter 18. “Optimizations.”

-On
Unroll loopsCheck to perform the optimization of loop unrolling. This is only done for loops whose number of iterations can be determined at compile time or run time.

Uncheck to not unroll loops.

-funroll-loops
Omit frame pointerCheck to not keep the Frame Pointer in a register for functions that don’t need one.

Uncheck to keep the Frame Pointer.

-fomit-frame-pointer
Unlimited procedural abstractionEnable the procedure abstraction optimization. There is no limit on the nesting level.-mpa
Procedural abstractionEnable the procedure abstraction optimization up to level n.
Equivalent to -mpa=n option, where n equals:
  • 0 - Optimization is disabled.
  • 1 - The first level of abstraction is allowed; that is, instruction sequences in the source code may be abstracted into a subroutine.
  • 2 or greater - 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.
-mpa=n
Align arraysSet the minimum alignment for array variables to be the largest power of two less than or equal to their total storage size, or the biggest alignment used on the machine, whichever is smaller.-falign-arrays
Table 6-7. Preprocessing and Messages Category
OptionDescriptionCommand Line
Include C dirsAdd the directory dir to the head of the list of directories to be searched for header files.

For more information, see Additional Search Paths and Directories

-I"dir"
Define C macrosDefine macro macro with the string 1 as its definition.-Dmacro
ANSI-std C supportCheck to support all (and only) ASCI C programs.

Uncheck to support ASCI and non-ASCI programs.

-ansi
Use CCI syntaxCheck if your code is written per the Common C Interface (CCI) syntax (see Chapter 2. “Common C Interface.”).

Uncheck if you are not.

-mcci
Use IAR syntaxCheck if your code is written per the Embedded Compiler Compatibility Mode syntax for IAR (see Appendix B. “Embedded Compiler Compatibility Mode”).

Uncheck if you are not.

-mext=IAR
ErrataThis option enables specific errata work-arounds identified by ID.

Valid values for ID change from time to time and may not be required for a particular variant. The ID all will enable all currently supported errata work-arounds. The ID list will display the currently supported errata identifiers along with a brief description of the errata.

-merrata=id
Smart IO forwarding level 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. Equivalent to -msmart-io=n option where n equals:
  • 0 - disables this option.
  • 1 - only convert the literal values it can prove.
  • 2 - causes the compiler to be optimistic and convert function calls with variable or unknown format arguments.
-msmart-io=n
Smart IO format stringsSpecifies what the format arguments are when the compiler is unable to determine them.
Make warnings into errorsCheck to halt compilation based on warnings as well as errors.

Uncheck to halt compilation based on errors only.

-Werror
Additional warningsCheck to enable all warnings.

Uncheck to disable warnings.

-Wall
Strict ANSI warningsCheck to issue all warnings demanded by strict ANSI C.

Uncheck to issue all warnings.

-pedantic
Disable ISR warnDisable warning for inappropriate use of ISR function names. By 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.-mno-isr-warn
Enable SFR warningsEnable warnings related to SFRs.-msfr-warn=on|off