Jump to main content
MPLAB® XC32 C/C++ Compiler User's Guide for PIC32M MCUs
Search
Notice to Development Tools Customers
1
Preface
1.1
Conventions Used in This Guide
1.2
Recommended Reading
2
Compiler Overview
2.1
Device Description
2.2
Compiler Description and Documentation
2.3
Compiler and Other Development Tools
3
How To's
3.1
Installing and Activating the Compiler
3.2
Invoking the Compiler
3.3
Writing Source Code
3.4
Getting My Application To Do What I Want
3.5
Understanding the Compilation Process
3.6
Fixing Code That Does Not Work
4
XC32 Toolchain and MPLAB X IDE
4.1
MPLAB X IDE and Tools Installation
4.2
MPLAB X IDE Setup
4.3
MPLAB X IDE Projects
4.4
Project Setup
4.5
Project Example
5
Command-line Driver
5.1
Invoking The Compiler
5.2
The C Compilation Sequence
5.3
The C++ Compilation Sequences
5.4
Runtime Files
5.5
Compiler Output
5.6
Compiler Messages
5.7
Driver Option Descriptions
6
ANSI C Standard Issues
6.1
Divergence Fom the ANSI C Standard
6.2
Extensions to the ANSI C Standard
6.3
Implementation-Defined Behavior
7
Device-Related Features
7.1
Device Support
7.2
Device Header Files
7.3
Configuration Bit Access
7.4
ID Locations
7.5
Using SFRs From C Code
7.6
Code Coverage
8
Supported Data Types and Variables
8.1
Identifiers
8.2
Data Representation
8.3
Integer Data Types
8.4
Floating-Point Data Types
8.5
Structures and Unions
8.6
Pointer Types
8.7
Complex Data Types
8.8
Constant Types and Formats
8.9
Standard Type Qualifiers
8.10
Variable Attributes
9
Memory Allocation and Access
9.1
Address Spaces
9.2
Variables in Data Memory
9.3
Auto Variable Allocation and Access
9.4
Variables in Program Memory
9.5
Variable in Registers
9.6
Application-Defined Memory Regions
9.7
Dynamic Memory Allocation
9.8
Memory Models
10
Floating-point Support
11
Fixed-Point Arithmetic Support
11.1
Enabling Fixed-Point Arithmetic Support
11.2
Data Types
11.3
Fixed-point Library Functions
11.4
Integer Representations
11.5
SIMD Variables
11.6
Accessing Elements in SIMD Variables
11.7
Array Alignment and Data Layout
11.8
Operations on Fixed-Point Variables
11.9
Operations on SIMD Variables
11.10
DSP Built-In Functions
11.11
DSP Control Register
11.12
Using Accumulators
11.13
Mixed-Mode Operations
11.14
Auto-Vectorization to SIMD
11.15
FIR Filter Example Project
11.16
Unsupported Features
12
Operators and Statements
12.1
Integral Promotion
12.2
Type References
12.3
Labels as Values
12.4
Conditional Operator Operands
12.5
Case Ranges
12.6
Has_builtin Operator
13
Register Usage
13.1
Register Usage
13.2
Register Conventions
14
Stack
14.1
Software Stack
14.2
Call Frame
14.3
Stack Guidance
15
Functions
15.1
Writing Functions
15.2
Function Attributes and Specifiers
15.3
Allocation of Function Code
15.4
Changing the Default Function Allocation
15.5
Function Size Limits
15.6
Function Parameters
15.7
Function Return Values
15.8
Calling Functions
15.9
Inline Functions
16
Interrupts
16.1
Interrupt Operation
16.2
Writing an Interrupt Service Routine
16.3
Associating a Handler Function with an Exception Vector
16.4
Exception Handlers
16.5
Context Switching
16.6
Latency
16.7
Nesting Interrupts
16.8
Enabling/Disabling Interrupts
16.9
ISR Considerations
17
Main, Runtime Start-up and Reset
17.1
The Main Function
17.2
Runtime Start-Up Code
18
Library Routines
18.1
Smart IO Routines
18.2
Using Library Routines
19
Mixing C/C++ and Assembly Language
19.1
Mixing Assembly Language and C Variables and Functions
19.2
Using Inline Assembly Language
19.3
Predefined Macros
20
Optimizations
20.1
Optimization Feature Summary
21
Preprocessing
21.1
C/C++ Language Comments
21.2
Preprocessor Directives
21.3
Pragma Directives
21.4
Predefined Macros
22
Linking Programs
22.1
Replacing Library Symbols
22.2
Linker-Defined Symbols
22.3
Default Linker Script
23
Embedded Compiler Compatibility Mode
23.1
Compiling in Compatibility Mode
23.2
Syntax Compatibility
23.3
Data Type
23.4
Operator
23.5
Extended Keywords
23.6
Intrinsic Functions
23.7
Pragmas
24
Common C Interface
24.1
Background - The Desire for Portable Code
24.2
Using the CCI
24.3
C Language Standard Refinement
24.4
C Language Standard Extensions
24.5
Compiler Features
25
C Implementation-Defined Behavior
25.1
Overview
25.2
Translation
25.3
Environment
25.4
Identifiers
25.5
Characters
25.6
Integers
25.7
Floating-Point
25.8
Arrays and Pointers
25.9
Hints
25.10
Structures, Unions, Enumerations, and Bit Fields
25.11
Qualifiers
25.12
Declarators
25.13
Statements
25.14
Pre-Processing Directives
25.15
Library Functions
25.16
Architecture
26
C++ Implementation-Defined Behavior
27
Deprecated Features
27.1
Variables in Specified Registers
27.2
Defining Global Register Variables
27.3
Specifying Registers for Local Variables
28
Built-in Functions
28.1
__builtin_bcc0 Built-in Function
28.2
__builtin_bsc0 Built-in Function
28.3
__builtin_bcsc0 Built-in Function
28.4
__builtin_bswap16 Built-in Function
28.5
__builtin_bswap32 Built-in Function
28.6
__builtin_bswap64 Built-in Function
28.7
__builtin_clz Built-in Function
28.8
__builtin_ctz Built-in Function
28.9
__builtin_disable_interrupts Built-in Function
28.10
__builtin_enable_interrupts Built-in Function
28.11
__builtin_get_isr_state Built-in Function
28.12
__builtin_has_attribute Built-in Function
28.13
__builtin_mfc0 Built-in Function
28.14
__builtin_mips_cache Built-in Function
28.15
__builtin_mtc0 Built-in Function
28.16
__builtin_mxc0 Built-in Function
28.17
void __builtin_nop(void)
28.18
__builtin_set_isr_state Built-in Function
28.19
__builtin_software_breakpoint Built-in Function
28.20
__builtin_section_begin Built-in Function
28.21
__builtin_section_end Built-in Function
28.22
__builtin_section_size Built-in Function
29
Built-In DSP Functions
30
PIC32 DSP Library
30.1
Overview
30.2
Fixed-Point Types
30.3
Saturation, Scaling, and Overflow
30.4
Array Alignment and Length Restrictions
30.5
Vector Math Functions
30.6
Filtering Functions
30.7
Frequency Domain Transform Functions
30.8
Video Processing Functions
31
PIC32 Debug-Support Library
31.1
Overview
31.2
Configuring Debug Input/Output for the Target And Tool
31.3
PIC32 Debugging Support Header
32
DSP Wrapper Functions
32.1
Overview
32.2
PIC32 DSP Wrapper Functions List
32.3
Differences Between Wrapper Functions and dsPIC® DSP Library
33
ASCII Character Set
34
Document Revision History
Microchip Information
Trademarks
Legal Notice
Microchip Devices Code Protection Feature