MPLAB® XC8 C Compiler
User’s Guide
2012 Microchip Technology Inc.
DS52053B
Note the following details of the code protection feature on Microchip devices:
•
Microchip products meet the specification contained in their particular Microchip Data Sheet.
•
Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the
intended manner and under normal conditions.
•
There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our
knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip’s Data
Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
•
Microchip is willing to work with the customer who is concerned about the integrity of their code.
•
Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as “unbreakable.”
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our
products. Attempts to break Microchip’s code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts
allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
Information contained in this publication regarding device
applications and the like is provided only for your convenience
and may be superseded by updates. It is your responsibility to
ensure that your application meets with your specifications.
MICROCHIP MAKES NO REPRESENTATIONS OR
WARRANTIES OF ANY KIND WHETHER EXPRESS OR
IMPLIED, WRITTEN OR ORAL, STATUTORY OR
OTHERWISE, RELATED TO THE INFORMATION,
INCLUDING BUT NOT LIMITED TO ITS CONDITION,
QUALITY, PERFORMANCE, MERCHANTABILITY OR
FITNESS FOR PURPOSE. Microchip disclaims all liability
arising from this information and its use. Use of Microchip
devices in life support and/or safety applications is entirely at
the buyer’s risk, and the buyer agrees to defend, indemnify and
hold harmless Microchip from any and all damages, claims,
suits, or expenses resulting from such use. No licenses are
conveyed, implicitly or otherwise, under any Microchip
intellectual property rights.
Trademarks
The Microchip name and logo, the Microchip logo, dsPIC,
KEELOQ, KEELOQ logo, MPLAB, PIC, PICmicro, PICSTART,
PIC32 logo, rfPIC and UNI/O are registered trademarks of
Microchip Technology Incorporated in the U.S.A. and other
countries.
FilterLab, Hampshire, HI-TECH C, Linear Active Thermistor,
MXDEV, MXLAB, SEEVAL and The Embedded Control
Solutions Company are registered trademarks of Microchip
Technology Incorporated in the U.S.A.
Analog-for-the-Digital Age, Application Maestro, chipKIT,
chipKIT logo, CodeGuard, dsPICDEM, dsPICDEM.net,
dsPICworks, dsSPEAK, ECAN, ECONOMONITOR,
FanSense, HI-TIDE, In-Circuit Serial Programming, ICSP,
Mindi, MiWi, MPASM, MPLAB Certified logo, MPLIB,
MPLINK, mTouch, Omniscient Code Generation, PICC,
PICC-18, PICDEM, PICDEM.net, PICkit, PICtail, REAL ICE,
rfLAB, Select Mode, Total Endurance, TSHARC,
UniWinDriver, WiperLock and ZENA are trademarks of
Microchip Technology Incorporated in the U.S.A. and other
countries.
SQTP is a service mark of Microchip Technology Incorporated
in the U.S.A.
All other trademarks mentioned herein are property of their
respective companies.
© 2012, Microchip Technology Incorporated, Printed in the
U.S.A., All Rights Reserved.
Printed on recycled paper.
ISBN: 978-1-62076-375-9
QUALITY MANAGEMENT SYSTEM
CERTIFIED BY DNV
== ISO/TS 16949 ==
DS52053B-page 2
Microchip received ISO/TS-16949:2009 certification for its worldwide
headquarters, design and wafer fabrication facilities in Chandler and
Tempe, Arizona; Gresham, Oregon and design centers in California
and India. The Company’s quality system processes and procedures
are for its PIC® MCUs and dsPIC® DSCs, KEELOQ® code hopping
devices, Serial EEPROMs, microperipherals, nonvolatile memory and
analog products. In addition, Microchip’s quality system for the design
and manufacture of development systems is ISO 9001:2000 certified.
2012 Microchip Technology Inc.
MPLAB® XC8 C COMPILER
USER’S GUIDE
Table of Contents
Preface ........................................................................................................................... 7
Chapter 1. Compiler Overview
1.1 Introduction ................................................................................................... 11
1.2 Compiler Description and Documentation .................................................... 11
1.3 Device Description ....................................................................................... 12
Chapter 2. Common C Interface
2.1 Introduction ................................................................................................... 13
2.2 Background – The Desire for Portable Code ............................................... 13
2.3 Using the CCI ............................................................................................... 16
2.4 ANSI Standard Refinement .......................................................................... 17
2.5 ANSI Standard Extensions ........................................................................... 25
2.6 Compiler Features ........................................................................................ 39
Chapter 3. How To’s
3.1 Introduction ................................................................................................... 41
3.2 Installing and Activating the Compiler .......................................................... 41
3.3 Invoking the Compiler ................................................................................... 43
3.4 Writing Source Code .................................................................................... 46
3.5 Getting My Application to Do What I Want ................................................... 56
3.6 Understanding the Compilation Process ...................................................... 60
3.7 Fixing Code That Does Not Work ................................................................. 67
Chapter 4. XC8 Command-line Driver
4.1 Introduction ................................................................................................... 71
4.2 Invoking the Compiler ................................................................................... 72
4.3 The Compilation Sequence .......................................................................... 75
4.4 Runtime Files ............................................................................................... 81
4.5 Compiler Output ........................................................................................... 84
4.6 Compiler Messages ...................................................................................... 86
4.7 XC8 Driver Options ...................................................................................... 91
4.8 Option Descriptions ...................................................................................... 92
4.9 MPLAB IDE V8 Universal Toolsuite Equivalents ........................................ 117
4.10 MPLAB X Universal Toolsuite Equivalents ............................................... 124
Chapter 5. C Language Features
5.1 Introduction ................................................................................................. 131
5.2 ANSI C Standard Issues ............................................................................ 131
5.3 Device-Related Features ............................................................................ 133
5.4 Supported Data Types and Variables ........................................................ 143
5.5 Memory Allocation and Access .................................................................. 165
2012 Microchip Technology Inc.
DS52053B-page 3
MPLAB® XC8 C Compiler User’s Guide
5.6 Operators and Statements ......................................................................... 179
5.7 Register Usage ........................................................................................... 181
5.8 Functions .................................................................................................... 182
5.9 Interrupts .................................................................................................... 189
5.10 Main, Runtime Startup and Reset ............................................................ 194
5.11 Library Routines ....................................................................................... 198
5.12 Mixing C and Assembly Code .................................................................. 200
5.13 Optimizations ............................................................................................ 208
5.14 Preprocessing .......................................................................................... 210
5.15 Linking Programs ..................................................................................... 222
Chapter 6. Macro Assembler
6.1 Introduction ................................................................................................. 241
6.2 Assembler Usage ....................................................................................... 241
6.3 Options ....................................................................................................... 242
6.4 MPLAB XC8 Assembly Language .............................................................. 246
6.5 Assembly-Level Optimizations ................................................................... 268
6.6 Assembly List Files ..................................................................................... 269
Chapter 7. Linker
7.1 Introduction ................................................................................................. 277
7.2 Operation .................................................................................................... 277
7.3 Relocation and Psects ................................................................................ 285
7.4 Map Files .................................................................................................... 286
Chapter 8. Utilities
8.1 Introduction ................................................................................................. 291
8.2 Librarian ..................................................................................................... 291
8.3 OBJTOHEX ................................................................................................ 295
8.4 CREF .......................................................................................................... 297
8.5 CROMWELL ............................................................................................... 300
8.6 HEXMATE .................................................................................................. 303
Appendix A. Library Functions
Appendix B. Error and Warning Messages
Appendix C. Implementation-Defined Behavior
C.1 Translation (G.3.1) ..................................................................................... 479
C.2 Environment (G.3.2) .................................................................................. 479
C.3 Identifiers (G.3.3) ....................................................................................... 480
C.4 Characters (G.3.4) ..................................................................................... 480
C.5 Integers (G.3.5) .......................................................................................... 481
C.6 Floating-Point (G.3.6) ................................................................................ 482
C.7 Arrays and Pointers (G.3.7) ....................................................................... 482
C.8 Registers (G.3.8) ....................................................................................... 482
C.9 Structures, Unions, Enumerations, and Bit-Fields (G.3.9) ......................... 483
C.10 Qualifiers (G.3.10) ................................................................................... 483
C.11 Declarators (G.3.11) ................................................................................ 483
DS52053B-page 4
2012 Microchip Technology Inc.
C.12 Statements (G.3.12) ................................................................................ 483
C.13 Preprocessing Directives (G.3.13) ........................................................... 484
C.14 Library Functions (G.3.14) ....................................................................... 485
Glossary ..................................................................................................................... 487
Index ........................................................................................................................... 507
Worldwide Sales and Service .................................................................................. 518
2012 Microchip Technology Inc.
DS52053B-page 5
MPLAB® XC8 C Compiler User’s Guide
NOTES:
DS52053B-page 6
2012 Microchip Technology Inc.
MPLAB® XC8 C COMPILER
USER’S GUIDE
Preface
NOTICE TO CUSTOMERS
All documentation becomes dated, and this manual is no exception. Microchip tools and
documentation are constantly evolving to meet customer needs, so some actual dialogs
and/or tool descriptions may differ from those in this document. Please refer to our web site
(www.microchip.com) to obtain the latest documentation available.
Documents are identified with a “DS” number. This number is located on the bottom of each
page, in front of the page number. The numbering convention for the DS number is
“DSXXXXXA”, where “XXXXX” is the document number and “A” is the revision level of the
document.
For the most up-to-date information on development tools, see the MPLAB® IDE online help.
Select the Help menu, and then Topics to open a list of available online help files.
INTRODUCTION
This chapter contains general information that will be useful to know before using the
MPLAB® XC8 C Compiler User’s Guide. Items discussed in this chapter include:
•
•
•
•
•
•
•
•
Document Layout
Conventions Used in this Guide
Warranty Registration
Recommended Reading
The Microchip Web Site
Development Systems Customer Change Notification Service
Customer Support
Document Revision History
DOCUMENT LAYOUT
This document describes how to use the MPLAB XC8 C Compiler. The manual layout
is as follows:
•
•
•
•
•
•
•
•
•
•
•
•
Chapter 1. Compiler Overview
Chapter 3. How To’s
Chapter 4. XC8 Command-line Driver
Chapter 5. C Language Features
Chapter 6. Macro Assembler
Chapter 7. Linker
Chapter 8. Utilities
Appendix A. Library Functions
Appendix B. Error and Warning Messages
Appendix C. Implementation-Defined Behavior
Glossary
Index
2012 Microchip Technology Inc.
DS52053B-page 7
MPLAB® XC8 C Compiler User’s Guide
CONVENTIONS USED IN THIS GUIDE
This manual uses the following documentation conventions:
DOCUMENTATION CONVENTIONS
Description
Arial font:
Italic characters
Initial caps
Quotes
Underlined, italic text with
right angle bracket
Bold characters
N‘Rnnnn
Text in angle brackets < >
Courier New font:
Plain Courier New
Represents
Examples
Referenced books
Emphasized text
A window
A dialog
A menu selection
A field name in a window or
dialog
A menu path
MPLAB® IDE User’s Guide
...is the only compiler...
the Output window
the Settings dialog
select Enable Programmer
“Save project before build”
A dialog button
A tab
A number in verilog format,
where N is the total number of
digits, R is the radix and n is a
digit.
A key on the keyboard
Click OK
Click the Power tab
4‘b0010, 2‘hF1
Italic Courier New
Sample source code
Filenames
File paths
Keywords
Command-line options
Bit values
Constants
A variable argument
Square brackets [ ]
Optional arguments
Curly brackets and pipe
character: { | }
Ellipses...
Choice of mutually exclusive
arguments; an OR selection
Replaces repeated text
Represents code supplied by
user
File>Save
Press ,
#define START
autoexec.bat
c:\mcc18\h
_asm, _endasm, static
-Opa+, -Opa0, 1
0xFF, ‘A’
file.o, where file can be
any valid filename
mcc18 [options] file
[options]
errorlevel {0|1}
var_name [,
var_name...]
void main (void)
{ ...
}
WARRANTY REGISTRATION
Please complete the enclosed Warranty Registration Card and mail it promptly.
Sending in the Warranty Registration Card entitles users to receive new product
updates. Interim software releases are available at the Microchip web site.
RECOMMENDED READING
This user’s guide describes how to use Chapter Name. Other useful documents are
listed below. The following Microchip documents are available and recommended as
supplemental reference resources.
DS52053B-page 8
2012 Microchip Technology Inc.
Preface
Readme for Chapter Name
For the latest information on using Chapter Name, read the “Readme for Chapter
Name.txt” file (an ASCII text file) in the Readmes subdirectory of the MPLAB® IDE
installation directory. The Readme file contains update information and known issues
that may not be included in this user’s guide.
Readme Files
For the latest information on using other tools, read the tool-specific Readme files in
the Readmes subdirectory of the MPLAB IDE installation directory. The Readme files
contain update information and known issues that may not be included in this user’s
guide.
THE MICROCHIP WEB SITE
Microchip provides online support via our web site at www.microchip.com. This web
site is used as a means to make files and information easily available to customers.
Accessible by using your favorite Internet browser, the web site contains the following
information:
• Product Support – Data sheets and errata, application notes and sample
programs, design resources, user’s guides and hardware support documents,
latest software releases and archived software
• General Technical Support – Frequently Asked Questions (FAQs), technical
support requests, online discussion groups, Microchip consultant program
member listing
• Business of Microchip – Product selector and ordering guides, latest Microchip
press releases, listing of seminars and events, listings of Microchip sales offices,
distributors and factory representatives
DEVELOPMENT SYSTEMS CUSTOMER CHANGE NOTIFICATION SERVICE
Microchip’s customer notification service helps keep customers current on Microchip
products. Subscribers will receive e-mail notification whenever there are changes,
updates, revisions or errata related to a specified product family or development tool of
interest.
To register, access the Microchip web site at www.microchip.com, click on Customer
Change Notification and follow the registration instructions.
The Development Systems product group categories are:
• Compilers – The latest information on Microchip C compilers and other language
tools. These include the MPLAB® C18 and MPLAB® C30 C compilers; MPASM™
and MPLAB® ASM30 assemblers; MPLINK™ and MPLAB LINK30 object linkers;
and MPLIB™ and MPLAB® LIB30 object librarians.
• Emulators – The latest information on Microchip in-circuit emulators.This
includes the MPLAB® ICE 2000 and MPLAB ICE 4000.
• In-Circuit Debuggers – The latest information on the Microchip In-Circuit
Debugger, MPLAB® ICD 2.
• MPLAB® IDE – The latest information on Microchip MPLAB IDE, the Windows®
Integrated Development Environment for development systems tools. This list is
focused on the MPLAB® IDE, MPLAB® SIM simulator, MPLAB® IDE Project Manager and general editing and debugging features.
• Programmers – The latest information on Microchip programmers. These include
the MPLAB® PM3 and PRO MATE® II device programmers and the PICSTART®
Plus and PICkit™ 1 development programmers.
2012 Microchip Technology Inc.
DS52053B-page 9
MPLAB® XC8 C Compiler User’s Guide
CUSTOMER SUPPORT
Users of Microchip products can receive assistance through several channels:
•
•
•
•
Distributor or Representative
Local Sales Office
Field Application Engineer (FAE)
Technical Support
Customers should contact their distributor, representative or field application engineer
(FAE) for support. Local sales offices are also available to help customers. A listing of
sales offices and locations is included in the back of this document.
Technical support is available through the web site at: http://support.microchip.com
DOCUMENT REVISION HISTORY
Revision B (July 2012)
•
•
•
•
•
•
•
•
•
•
•
•
•
•
Added 'how tos' chapter.
Expanded section relating to PIC18 erratas.
Updated the section relating to compiler optimization settings.
Updated MPLAB v8 and MPLAB X IDE project option dialogs.
Added sections describing PIC18 far qualifier and inline function qualifier.
Expanded section describing the operation of the main() function
Expanded information about equivalent assembly symbols for Baseline parts.
Updated the table of predefined macro symbols.
Added section on #pragma addrqual
Added sections to do with inline-ing functions
Updated diagrams and text associated with call graphs in the list file
Updated library function section to be consistent with packaged libraries
Added new compiler warnings and errors.
Added new chapter describing the Common Compiler Interface Standard (CCI)
Revision A (February 2012)
Initial release of this document.
DS52053B-page 10
2012 Microchip Technology Inc.
MPLAB® XC8 C COMPILER
USER’S GUIDE
Chapter 1. Compiler Overview
1.1
INTRODUCTION
This chapter is an overview of the MPLAB XC8 C Compiler, including these topics.
• Compiler Description and Documentation
• Device Description
1.2
COMPILER DESCRIPTION AND DOCUMENTATION
The MPLAB® XC8 C Compiler is a free-standing, optimizing ANSI C compiler. It supports all 8-bit PIC® microcontrollers: PIC10, PIC12, PIC16 and PIC18 series devices,
as well as the PIC14000 device.
The compiler is available for several popular operating systems, including 32- and
64-bit Windows®, Linux and Apple OS X.
The compiler is available in three operating modes: Free, Standard or PRO. The Standard and PRO operating modes are licensed modes and require a serial number to
enable them. Free mode is available for unlicensed customers. The basic compiler
operation, supported devices and available memory are identical across all modes.
The modes only differ in the level of optimization employed by the compiler.
1.2.1
Conventions
Throughout this manual, the term “compiler” is used. It can refer to all, or a subset of,
the collection of applications that comprise the MPLAB XC8 C Compiler. When it is not
important to identify which application performed an action, it will be attributed to the
compiler.
Likewise, “compiler” is often used to refer to the command-line driver. Although specifically, the driver for the MPLAB XC8 C Compiler package is called xc8. The driver and
its options are discussed in Section 4.7 “XC8 Driver Options”. Accordingly, “compiler
options” commonly relates to command-line driver options.
In a similar fashion, “compilation” refers to all or a selection of steps involved in
generating source code into an executable binary image.
2012 Microchip Technology Inc.
DS52053B-page 11
MPLAB® XC8 C Compiler User’s Guide
1.3
DEVICE DESCRIPTION
This compiler supports 8-bit Microchip PIC devices with baseline, Mid-Range,
Enhanced Mid-Range, and PIC18 cores. The following descriptions indicate the
distinctions within those device cores:
The baseline core uses a 12-bit-wide instruction set and is available in PIC10, PIC12
and PIC16 part numbers.
The Mid-Range core uses a 14-bit-wide instruction set that includes more instructions
than the baseline core. It has larger data memory banks and program memory pages,
as well. It is available in PIC12, PIC14 and PIC16 part numbers.
The Enhanced Mid-Range core also uses a 14-bit-wide instruction set, but incorporates
additional instructions and features. There are both PIC12 and PIC16 part numbers
that are based on the Enhanced Mid-Range core.
The PIC18 core instruction set is 16-bits wide and features additional instructions and
an expanded register set. PIC18 core devices have part numbers that begin with
PIC18.
The compiler takes advantage of the target device’s instruction set, addressing modes
memory and registers whenever possible.
See Section 4.8.21 “--CHIPINFO: Display List of Supported Devices” for
information on finding the full list of devices supported by the compiler.
DS52053B-page 12
2012 Microchip Technology Inc.
MPLAB® XC8 C COMPILER
USER’S GUIDE
Chapter 2. Common C Interface
2.1
INTRODUCTION
The Common C Interface (CCI) is available with all MPLAB XC C compilers and is
designed to enhance code portability between these compilers. For example,
CCI-conforming code would make it easier to port from a PIC18 MCU using the MPLAB
XC8 C compiler to a PIC24 MCU using the MPLAB XC16 C compiler.
The CCI assumes that your source code already conforms to the ANSI Standard. If you
intend to use the CCI, it is your responsibility to write code that conforms. Legacy projects will need to be migrated to achieve conformance. A compiler option must also be
set to ensure that the operation of the compiler is consistent with the interface when the
project is built.
The following topics are examined in this chapter of the MPLAB XC8 C Compiler User’s
Guide:
•
•
•
•
2.2
ANSI Standard Extensions
Using the CCI
ANSI Standard Refinement
ANSI Standard Extensions
BACKGROUND – THE DESIRE FOR PORTABLE CODE
All programmers want to write portable source code.
Portability means that the same source code can be compiled and run in a different
execution environment than that for which it was written. Rarely can code be one hundred percent portable, but the more tolerant it is to change, the less time and effort it
takes to have it running in a new environment.
Embedded engineers typically think of code portability as being across target devices,
but this is only part of the situation. The same code could be compiled for the same
target but with a different compiler. Differences between those compilers might lead to
the code failing at compile time or runtime, so this must be considered as well.
You may only write code for one target device and only use one brand of compiler, but
if there is no regulation of the compiler’s operation, simply updating your compiler
version may change your code’s behavior.
Code must be portable across targets, tools, and time to be truly flexible.
Clearly, this portability cannot be achieved by the programmer alone, since the compiler vendors can base their products on different technologies, implement different features and code syntax, or improve the way their product works. Many a great compiler
optimization has broken many an unsuspecting project.
Standards for the C language have been developed to ensure that change is managed
and code is more portable. The American National Standards Institute (ANSI) publishes standards for many disciplines, including programming languages. The ANSI C
Standard is a universally adopted standard for the C programming language.
2012 Microchip Technology Inc.
DS52053A-page 13
MPLAB® XC8 C Compiler User’s Guide
2.2.1
The ANSI Standard
The ANSI C Standard has to reconcile two opposing goals: freedom for compilers vendors to target new devices and improve code generation, with the known functional
operation of source code for programmers. If both goals can be met, source code can
be made portable.
The standard is implemented as a set of rules which detail not only the syntax that a
conforming C program must follow, but the semantic rules by which that program will
be interpreted. Thus, for a compiler to conform to the standard, it must ensure that a
conforming C program functions as described by the standard.
The standard describes implementation, the set of tools and the runtime environment
on which the code will run. If any of these change, e.g., you build for, and run on, a different target device, or if you update the version of the compiler you use to build, then
you are using a different implementation.
The standard uses the term behavior to mean the external appearance or action of the
program. It has nothing to do with how a program is encoded.
Since the standard is trying to achieve goals that could be construed as conflicting,
some specifications appear somewhat vague. For example, the standard states that an
int type must be able to hold at least a 16-bit value, but it does not go as far as saying
what the size of an int actually is; and the action of right-shifting a signed integer can
produce different results on different implementations; yet, these different results are
still ANSI C compliant.
If the standard is too strict, device architectures may not allow the compiler to conform.1
But, if it is too weak, programmers would see wildly differing results within different
compilers and architectures, and the standard would loose its effectiveness.
The standard organizes source code whose behavior is not fully defined into groups
that include the following behaviors:
Implementation-defined behavior
This is unspecified behavior where each implementation documents how the choice
is made.
Unspecified behavior
The standard provides two or more possibilities and imposes no further requirements
on which possibility is chosen in any particular instance.
Undefined behavior
This is behavior for which the standard imposes no requirements.
Code that strictly conforms to the standard does not produce output that is dependent
on any unspecified, undefined, or implementation-defined behavior. The size of an
int, which we used as an example earlier, falls into the category of behavior that is
defined by implementation. That is to say, the size of an int is defined by which compiler is being used, how that compiler is being used, and the device that is being targeted.
All the MPLAB XC compilers conform to the ANS X3.159-1989 Standard for programming languages (with the exception of the XC8 compiler’s inability to allow recursion,
as mentioned in the footnote). This is commonly called the C89 Standard. Some features from the later standard, C99, are also supported.
1. Case in point: The mid-range PIC® microcontrollers do not have a data stack. Because a compiler
targeting this device cannot implement recursion, it (strictly speaking) cannot conform to the ANSI
C Standard. This example illustrate a situation in which the standard is too strict for mid-range
devices and tools.
DS52053A-page 14
2012 Microchip Technology Inc.
Common C Interface
For freestanding implementations – or for what we typically call embedded applications
– the standard allows non-standard extensions to the language, but obviously does not
enforce how they are specified or how they work. When working so closely to the
device hardware, a programmer needs a means of specifying device setup and interrupts, as well as utilizing the often complex world of small-device memory
architectures. This cannot be offered by the standard in a consistent way.
While the ANSI C Standard provides a mutual understanding for programmers and
compiler vendors, programmers need to consider the implementation-defined behavior
of their tools and the probability that they may need to use extensions to the C language
that are non-standard. Both of these circumstances can have an impact on code portability.
2.2.2
The Common C Interface
The Common C Interface (CCI) supplements the ANSI C Standard and makes it easier
for programmers to achieve consistent outcomes on all Microchip devices when using
any of the MPLAB XC C compilers.
It delivers the following improvements, all designed with portability in mind.
Refinement of the ANSI C Standard
The CCI documents specific behavior for some code in which actions are implementation-defined behavior under the ANSI C Standard. For example, the result of
right-shifting a signed integer is fully defined by the CCI. Note that many
implementation-defined items that closely couple with device characteristics, such as
the size of an int, are not defined by the CCI.
Consistent syntax for non-standard extensions
The CCI non-standard extensions are mostly implemented using keywords with a uniform syntax. They replace keywords, macros and attributes that are the native compiler implementation. The interpretation of the keyword may differ across each compiler, and any arguments to the keywords may be device specific.
Coding guidelines
The CCI may indicate advice on how code should be written so that it can be ported
to other devices or compilers. While you may choose not to follow the advice, it will
not conform to the CCI.
2012 Microchip Technology Inc.
DS52053A-page 15
MPLAB® XC8 C Compiler User’s Guide
2.3
USING THE CCI
The CCI allows enhanced portability by refining implementation-defined behavior and
standardizing the syntax for extensions to the language.
The CCI is something you choose to follow and put into effect, thus it is relevant for new
projects, although you may choose to modify existing projects so they conform.
For your project to conform to the CCI, you must do the following things.
Enable the CCI
Select the MPLAB IDE widget Use CCI Syntax in your project, or use the
command-line option that is equivalent.
Include in every module
Some CCI features are only enabled if this header is seen by the compiler.
Ensure ANSI compliance
Code that does not conform to the ANSI C Standard does not confirm to the CCI.
Observe refinements to ANSI by the CCI
Some ANSI implementation-defined behavior is defined explicitly by the CCI.
Use the CCI extensions to the language
Use the CCI extensions rather than the native language extensions
The next sections detail specific items associated with the CCI. These items are segregated into those that refine the standard, those that deal with the ANSI C Standard
extensions, and other miscellaneous compiler options and usage. Guidelines are indicated with these items.
If any implementation-defined behavior or any non-standard extension is not discussed
in this document, then it is not part of the CCI. For example, GCC case ranges, label
addresses and 24-bit short long types are not part of the CCI. Programs which use
these features do not conform to the CCI. The compiler may issue a warning or error
to indicate when you use a non-CCI feature and the CCI is enabled.
DS52053A-page 16
2012 Microchip Technology Inc.
Common C Interface
2.4
ANSI STANDARD REFINEMENT
The following topics describe how the CCI refines the implementation-defined
behaviors outlined in the ANSI C Standard.
2.4.1
Source File Encoding
Under the CCI, a source file must be written using characters from the 7-bit ASCII set.
Lines may be terminated using a line feed ('\n') or carriage return ('\r') that is immediately followed by a line feed. Escaped characters may be used in character constants
or string literals to represent extended characters not in the basic character set.
2.4.1.1
EXAMPLE
The following shows a string constant being defined that uses escaped characters.
const char myName[] = "Bj\370rk\n";
2.4.1.2
DIFFERENCES
All compilers have used this character set.
2.4.1.3
MIGRATION TO THE CCI
No action required.
2.4.2
The Prototype for main
The prototype for the main() function is
int main(void);
2.4.2.1
EXAMPLE
The following shows an example of how main() might be defined
int main(void)
{
while(1)
process();
}
2.4.2.2
DIFFERENCES
The 8-bit compilers used a void return type for this function.
2.4.2.3
MIGRATION TO THE CCI
Each program has one definition for the main() function. Confirm the return type for
main() in all projects previously compiled for 8-bit targets.
2.4.3
Header File Specification
Header file specifications that use directory separators do not conform to the CCI.
2.4.3.1
EXAMPLE
The following example shows two conforming include directives.
#include
#include "global.h"
2012 Microchip Technology Inc.
DS52053A-page 17
MPLAB® XC8 C Compiler User’s Guide
2.4.3.2
DIFFERENCES
Header file specifications that use directory separators have been allowed in previous
versions of all compilers. Compatibility problems arose when Windows-style separators “\” were used and the code compiled under other host operating systems. Under
the CCI, no directory specifiers should be used.
2.4.3.3
MIGRATION TO THE CCI
Any #include directives that use directory separators in the header file specifications
should be changed. Remove all but the header file name in the directive. Add the directory path to the compiler’s include search path or MPLAB IDE equivalent. This will force
the compiler to search the directories specified with this option.
For example, the following code:
#include
should be changed to:
#include
and the path to the inc directory added to the compiler’s header search path in your
MPLAB IDE project properties, or on the command-line as follows:
-Ilcd
2.4.4
Include Search Paths
When you include a header file under the CCI, the file should be discoverable in the
paths searched by the compiler detailed below.
For any header files specified in angle bracket delimiters < >, the search paths should
be those specified by -I options (or the equivalent MPLAB IDE option), then the standard compiler include directories. The -I options are searched in the order in which
they are specified.
For any file specified in quote characters " ", the search paths should first be the current working directory. In the case of an MPLAB X project, the current working directory
is the directory in which the C source file is located. If unsuccessful, the search paths
should be the same directories searched when the header files is specified in angle
bracket delimiters.
Any other options to specify search paths for header files do not conform to the CCI.
2.4.4.1
EXAMPLE
If including a header file as in the following directive
#include "myGlobals.h"
The header file should be locatable in the current working directory, or the paths specified by any -I options, or the standard compiler directories. If it is located elsewhere,
this does not conform to the CCI.
2.4.4.2
DIFFERENCES
The compiler operation under the CCI is not changed. This is purely a coding guide line.
2.4.4.3
MIGRATION TO THE CCI
Remove any option that specifies header file search paths other than the -I option (or
the equivalent MPLAB IDE option), and use the -I option in place of this. Ensure the
header file can be found in the directories specified in this section.
DS52053A-page 18
2012 Microchip Technology Inc.
Common C Interface
2.4.5
The Number of Significant Initial Characters in an Identifier
At least the first 255 characters in an identifier (internal and external) are significant.
This extends upon the requirement of the ANSI C Standard which states a lower number of significant characters are used to identify an object.
2.4.5.1
EXAMPLE
The following example shows two poorly named variables, but names which are
considered unique under the CCI.
int stateOfPortBWhenTheOperatorHasSelectedAutomaticModeAndMotorIsRunningFast;
int stateOfPortBWhenTheOperatorHasSelectedAutomaticModeAndMotorIsRunningSlow;
2.4.5.2
DIFFERENCES
Former 8-bit compilers used 31 significant characters by default, but an option allowed
this to be extended.
The 16- and 32-bit compilers did not impose a limit on the number of significant characters.
2.4.5.3
MIGRATION TO THE CCI
No action required. You may take advantage of the less restrictive naming scheme.
2.4.6
Sizes of Types
The sizes of the basic C types, for example char, int and long, are not fully defined
by the CCI. These types, by design, reflect the size of registers and other architectural
features in the target device. They allow the device to efficiently access objects of this
type. The ANSI C Standard does, however, indicate minimum requirements for these
types, as specified in .
If you need fixed-size types in your project, use the types defined in , e.g.,
uint8_t or int16_t. These types are consistently defined across all XC compilers,
even outside of the CCI.
Essentially, the C language offers a choice of two groups of types: those that offer sizes
and formats that are tailored to the device you are using; or those that have a fixed size,
regardless of the target.
2.4.6.1
EXAMPLE
The following example shows the definition of a variable, native, whose size will allow
efficient access on the target device; and a variable, fixed, whose size is clearly indicated and remains fixed, even though it may not allow efficient access on every device.
int native;
int16_t fixed;
2.4.6.2
DIFFERENCES
This is consistent with previous types implemented by the compiler.
2.4.6.3
MIGRATION TO THE CCI
If you require a C type that has a fixed size, regardless of the target device, use one of
the types defined by .
2012 Microchip Technology Inc.
DS52053A-page 19
MPLAB® XC8 C Compiler User’s Guide
2.4.7
Plain char Types
The type of a plain char is unsigned char. It is generally recommended that all definitions for the char type explicitly state the signedness of the object.
2.4.7.1
EXAMPLE
The following example
char foobar;
defines an unsigned char object called foobar.
2.4.7.2
DIFFERENCES
The 8-bit compilers have always treated plain char as an unsigned type.
The 16- and 32-bit compilers used signed char as the default plain char type. The
-funsigned-char option on those compilers changed the default type to be
unsigned char.
2.4.7.3
MIGRATION TO THE CCI
Any definition of an object defined as a plain char and using the 16- or 32-bit compilers
needs review. Any plain char that was intended to be a signed quantity should be
replaced with an explicit definition, for example.
signed char foobar;
You may use the -funsigned-char option on XC16/32 to change the type of plain
char, but since this option is not supported on XC8, the code is not strictly conforming.
2.4.8
Signed Integer Representation
The value of a signed integer is determined by taking the two’s complement of the integer.
2.4.8.1
EXAMPLE
The following shows a variable, test, that is assigned the value -28 decimal.
signed char test = 0xE4;
2.4.8.2
DIFFERENCES
All compilers have represented signed integers in the way described in this section.
2.4.8.3
MIGRATION TO THE CCI
No action required.
DS52053A-page 20
2012 Microchip Technology Inc.
Common C Interface
2.4.9
Integer conversion
When converting an integer type to a signed integer of insufficient size, the original
value is truncated from the most-significant bit to accommodate the target size.
2.4.9.1
EXAMPLE
The following shows an assignment of a value that will be truncated.
signed char destination;
unsigned int source = 0x12FE;
destination = source;
Under the CCI, the value of destination after the alignment will be -2 (i.e., the bit
pattern 0xFE).
2.4.9.2
DIFFERENCES
All compilers have performed integer conversion in an identical fashion to that
described in this section.
2.4.9.3
MIGRATION TO THE CCI
No action required.
2.4.10
Bit-wise Operations on Signed Values
Bitwise operations on signed values act on the two’s complement representation,
including the sign bit. See also Section 2.4.11 “Right-shifting Signed Values”.
2.4.10.1
EXAMPLE
The following shows an example of a negative quantity involved in a bitwise AND operation.
signed char output, input = -13;
output = input & 0x7E;
Under the CCI, the value of output after the assignment will be 0x72.
2.4.10.2
DIFFERENCES
All compilers have performed bitwise operations in an identical fashion to that
described in this section.
2.4.10.3
MIGRATION TO THE CCI
No action required.
2.4.11
Right-shifting Signed Values
Right-shifting a signed value will involve sign extension. This will preserve the sign of
the original value.
2.4.11.1
EXAMPLE
The following shows an example of a negative quantity involved in a bitwise AND
operation.
signed char input, output = -13;
output = input >> 3;
Under the CCI, the value of output after the assignment will be -2 (i.e., the bit pattern
0xFE).
2012 Microchip Technology Inc.
DS52053A-page 21
MPLAB® XC8 C Compiler User’s Guide
2.4.11.2
DIFFERENCES
All compilers have performed right shifting as described in this section.
2.4.11.3
MIGRATION TO THE CCI
No action required.
2.4.12
Conversion of Union Member Accessed Using Member With
Different Type
If a union defines several members of different types and you use one member identifier to try to access the contents of another (whether any conversion is applied to the
result) is implementation-defined behavior in the standard. In the CCI, no conversion is
applied and the bytes of the union object are interpreted as an object of the type of the
member being accessed, without regard for alignment or other possible invalid conditions.
2.4.12.1
EXAMPLE
The following shows an example of a union defining several members.
union {
signed char code;
unsigned int data;
float offset;
} foobar;
Code that attempts to extract offset by reading data is not guaranteed to read the
correct value.
float result;
result = foobbar.data;
2.4.12.2
DIFFERENCES
All compilers have not converted union members accessed via other members.
2.4.12.3
MIGRATION TO THE CCI
No action required.
2.4.13
Default Bit-field int Type
The type of a bit-field specified as a plain int will be identical to that of one defined
using unsigned int. This is quite different to other objects where the types int,
signed and signed int are synonymous. It is recommended that the signedness of
the bit-field be explicitly stated in all bit-field definitions.
2.4.13.1
EXAMPLE
The following shows an example of a structure tag containing bit-fields which are
unsigned integers and with the size specified.
struct
int
int
int
};
DS52053A-page 22
OUTPUTS {
direction :1;
parity
:3;
value
:4;
2012 Microchip Technology Inc.
Common C Interface
2.4.13.2
DIFFERENCES
The 8-bit compilers have previously issued a warning if type int was used for bit-fields,
but would implement the bit-field with an unsigned int type.
The 16- and 32-bit compilers have implemented bit-fields defined using int as having
a signed int type, unless the option -funsigned-bitfields was specified.
2.4.13.3
MIGRATION TO THE CCI
Any code that defines a bit-field with the plain int type should be reviewed. If the intention was for these to be signed quantities, then the type of these should be changed to
signed int, for example, in:
struct WAYPT {
int log
int direction
};
:3;
:4;
the bit-field type should be changed to signed int, as in:
struct WAYPT {
signed int log
:3;
signed int direction :4;
};
2.4.14
Bit-fields Straddling a Storage Unit Boundary
Whether a bit-field can straddle a storage unit boundary is implementation-defined
behavior in the standard. In the CCI, bit-fields will not straddle a storage unit boundary;
a new storage unit will be allocated to the structure, and padding bits will fill the gap.
Note that the size of a storage unit differs with each compiler as this is based on the
size of the base data type (e.g., int) from which the bit-field type is derived. On 8-bit
compilers this unit is 8-bits in size; for 16-bit compilers, it is 16 bits; and for 32-bit compilers, it is 32 bits in size.
2.4.14.1
EXAMPLE
The following shows a structure containing bit-fields being defined.
struct {
unsigned first : 6;
unsigned second :6;
} order;
Under the CCI and using XC8, the storage allocation unit is byte sized. The bit-field
second, will be allocated a new storage unit since there are only 2 bits remaining in
the first storage unit in which first is allocated. The size of this structure, order, will
be 2 bytes.
2.4.14.2
DIFFERENCES
This allocation is identical with that used by all previous compilers.
2.4.14.3
MIGRATION TO THE CCI
No action required.
2.4.15
The Allocation Order of Bits-field
The memory ordering of bit-fields into their storage unit is not specified by the ANSI C
Standard. In the CCI, the first bit defined will be the least significant bit of the storage
unit in which it will be allocated.
2012 Microchip Technology Inc.
DS52053A-page 23
MPLAB® XC8 C Compiler User’s Guide
2.4.15.1
EXAMPLE
The following shows a structure containing bit-fields being defined.
struct {
unsigned lo : 1;
unsigned mid :6;
unsigned hi : 1;
} foo;
The bit-field lo will be assigned the least significant bit of the storage unit assigned to
the structure foo. The bit-field mid will be assigned the next 6 least significant bits, and
hi, the most significant bit of that same storage unit byte.
2.4.15.2
DIFFERENCES
This is identical with the previous operation of all compilers.
2.4.15.3
MIGRATION TO THE CCI
No action required.
2.4.16
The NULL macro
The NULL macro is defined in ; however, its definition is implementation-defined behavior. Under the CCI, the definition of NULL is the expression (0).
2.4.16.1
EXAMPLE
The following shows a pointer being assigned a null pointer constant via the NULL
macro.
int * ip = NULL;
The value of NULL, (0), is implicitly cast to the destination type.
2.4.16.2
DIFFERENCES
The 32-bit compilers previously assigned NULL the expression ((void *)0).
2.4.16.3
MIGRATION TO THE CCI
No action required.
2.4.17
Floating-point sizes
Under the CCI, floating-point types must not be smaller than 32 bits in size.
2.4.17.1
EXAMPLE
The following shows the definition for outY, which will be at least 32-bit in size.
float outY;
2.4.17.2
DIFFERENCES
The 8-bit compilers have allowed the use of 24-bit float and double types.
2.4.17.3
MIGRATION TO THE CCI
When using 8-bit compilers, the float and double type will automatically be made
32 bits in size once the CCI mode is enabled. Review any source code that may have
assumed a float or double type and may have been 24 bits in size.
No migration is required for other compilers.
DS52053A-page 24
2012 Microchip Technology Inc.
Common C Interface
2.5
ANSI STANDARD EXTENSIONS
The following topics describe how the CCI provides device-specific extensions to the
standard.
2.5.1
Generic Header File
A single header file must be used to declare all compiler- and device-specific
types and SFRs. You must include this file into every module to conform with the CCI.
Some CCI definitions depend on this header being seen.
2.5.1.1
EXAMPLE
The following shows this header file being included, thus allowing conformance with the
CCI, as well as allowing access to SFRs.
#include
2.5.1.2
DIFFERENCES
Some 8-bit compilers used as the equivalent header. Previous versions of
the 16- and 32-bit compilers used a variety of headers to do the same job.
2.5.1.3
MIGRATION TO THE CCI
Change:
#include
used previously in 8-bit compiler code, or family-specific header files as in the following
examples:
#include
#include
#include
#include
#include
"p30f6014.h"
to:
#include
2.5.2
Absolute addressing
Variables and functions can be placed at an absolute address by using the __at()
construct.qualifier Note that XC16/32 may require the variable or function to be placed
in a special section for absolute addressing to work. Stack-based (auto and parameter) variables cannot use the __at() specifier.
2.5.2.1
EXAMPLE
The following shows two variables and a function being made absolute.
int scanMode __at(0x200);
const char keys[] __at(123) = { ’r’, ’s’, ’u’, ’d’};
int modify(int x) __at(0x1000) {
return x * 2 + 3;
}
2.5.2.2
DIFFERENCES
The 8-bit compilers have used an @ symbol to specify an absolute address.
The 16- and 32-bit compilers have used the address attribute to specify an object’s
address.
2012 Microchip Technology Inc.
DS52053A-page 25
MPLAB® XC8 C Compiler User’s Guide
2.5.2.3
MIGRATION TO THE CCI
Avoid making objects and functions absolute if possible.
In XC8, change absolute object definitions such as the following example:
int scanMode @ 0x200;
to:
int scanMode __at(0x200);
In XC16/32, change code such as:
int scanMode __attribute__(address(0x200)));
to:
int scanMode __at(0x200);
2.5.2.4
CAVEATS
If the __at() and __section() specifiers are both applied to an object when using
XC8, the __section() specifier is currently ignored.
2.5.3
Far Objects and Functions
The __far qualifier may be used to indicate that variables or functions may be located
in ‘far memory’. Exactly what constitutes far memory is dependent on the target device,
but it is typically memory that requires more complex code to access. Expressions
involving far-qualified objects may generate slower and larger code.
Use the native keywords discussed in the Differences section to look up information on
the semantics of this qualifier.
Some devices may not have such memory implemented, in which case, use of this
qualifier will be ignored. Stack-based (auto and parameter) variables cannot use the
__far specifier.
2.5.3.1
EXAMPLE
The following shows a variable and function qualified using __far.
__far int serialNo;
__far int ext_getCond(int selector);
2.5.3.2
DIFFERENCES
The 8-bit compilers have used the qualifier far to indicate this meaning. Functions
could not be qualified as far.
The 16-bit compilers have used the far attribute with both variables and functions.
The 32-bit compilers have used the far attribute with functions, only.
DS52053A-page 26
2012 Microchip Technology Inc.
Common C Interface
2.5.3.3
MIGRATION TO THE CCI
For 8-bit compilers, change any occurrence of the far qualifier, as in the following
example:
far char template[20];
to __far, i.e., __far char template[20];
In the 16- and 32-bit compilers, change any occurrence of the far attribute, as in the
following
void bar(void) __attribute__ ((far));
int tblIdx __attribute__ ((far));
to
void __far bar(void);
int __far tblIdx;
2.5.3.4
CAVEATS
None.
2.5.4
Near Objects
The __near qualifier may be used to indicate that variables or functions may be
located in ‘near memory’. Exactly what constitutes near memory is dependent on the
target device, but it is typically memory that can be accessed with less complex code.
Expressions involving near-qualified objects may be faster and result in smaller code.
Use the native keywords discussed in the Differences section to look up information on
the semantics of this qualifier.
Some devices may not have such memory implemented, in which case, use of this
qualifier will be ignored. Stack-based (auto and parameter) variables cannot use the
__near specifier.
2.5.4.1
EXAMPLE
The following shows a variable and function qualified using __near.
__near int serialNo;
__near int ext_getCond(int selector);
2.5.4.2
DIFFERENCES
The 8-bit compilers have used the qualifier near to indicate this meaning. Functions
could not be qualified as near.
The 16-bit compilers have used the near attribute with both variables and functions.
The 32-bit compilers have used the near attribute for functions, only.
2012 Microchip Technology Inc.
DS52053A-page 27
MPLAB® XC8 C Compiler User’s Guide
2.5.4.3
MIGRATION TO THE CCI
For 8-bit compilers, change any occurrence of the near qualifier, as in the following
example:
near char template[20];
to __near, i.e., __near char template[20];
In 16- and 32-bit compilers, change any occurrence of the near attribute, as in the following
void bar(void) __attribute__ ((near));
int tblIdx __attribute__ ((near));
to
void __near bar(void);
int __near tblIdx;
2.5.4.4
CAVEATS
None.
2.5.5
Persistent Objects
The __persistent qualifier may be used to indicate that variables should not be
cleared by the runtime startup code.
Use the native keywords discussed in the Differences section to look up information on
the semantics of this qualifier.
2.5.5.1
EXAMPLE
The following shows a variable qualified using __persistent.
__persistent int serialNo;
2.5.5.2
DIFFERENCES
The 8-bit compilers have used the qualifier, persistent, to indicate this meaning.
The 16- and 32-bit compilers have used the persistent attribute with variables to
indicate they were not to be cleared.
2.5.5.3
MIGRATION TO THE CCI
With 8-bit compilers, change any occurrence of the persistent qualifier, as in the following example:
persistent char template[20];
to __persistent, i.e., __persistent char template[20];
For the 16- and 32-bit compilers, change any occurrence of the persistent attribute,
as in the following
int tblIdx __attribute__ ((persistent));
to
int __persistent tblIdx;
2.5.5.4
CAVEATS
None.
DS52053A-page 28
2012 Microchip Technology Inc.
Common C Interface
2.5.6
X and Y Data Objects
The __xdata and __ydata qualifiers may be used to indicate that variables may be
located in special memory regions. Exactly what constitutes X and Y memory is dependent on the target device, but it is typically memory that can be accessed independently
on separate buses. Such memory is often required for some DSP instructions.
Use the native keywords discussed in the Differences section to look up information on
the semantics of these qualifiers.
Some devices may not have such memory implemented; in which case, use of these
qualifiers will be ignored.
2.5.6.1
EXAMPLE
The following shows a variable qualified using __xdata, as well as another variable
qualified with __ydata.
__xdata char data[16];
__ydata char coeffs[4];
2.5.6.2
DIFFERENCES
The 16-bit compilers have used the xmemory and ymemory space attribute with
variables.
Equivalent specifiers have never been defined for any other compiler.
2.5.6.3
MIGRATION TO THE CCI
For 16-bit compilers, change any occurrence of the space attributes xmemory or
ymemory, as in the following example:
char __attribute__((space(xmemory)))template[20];
to __xdata, or __ydata, i.e., __xdata char template[20];
2.5.6.4
CAVEATS
None.
2.5.7
Banked Data Objects
The __bank(num) qualifier may be used to indicate that variables may be located in
a particular data memory bank. The number, num, represents the bank number. Exactly
what constitutes banked memory is dependent on the target device, but it is typically a
subdivision of data memory to allow for assembly instructions with a limited address
width field.
Use the native keywords discussed in the Differences section to look up information on
the semantics of these qualifiers.
Some devices may not have banked data memory implemented, in which case, use of
this qualifier will be ignored. The number of data banks implemented will vary from one
device to another.
2.5.7.1
EXAMPLE
The following shows a variable qualified using __bank().
__bank(0) char start;
__bank(5) char stop;
2012 Microchip Technology Inc.
DS52053A-page 29
MPLAB® XC8 C Compiler User’s Guide
2.5.7.2
DIFFERENCES
The 8-bit compilers have used the four qualifiers bank0, bank1, bank2 and bank3 to
indicate the same, albeit more limited, memory placement.
Equivalent specifiers have never been defined for any other compiler.
2.5.7.3
MIGRATION TO THE CCI
For 8-bit compilers, change any occurrence of the bankx qualifiers, as in the following
example:
bank2 int logEntry;
to __bank(), i.e., __bank(2) int logEntry;
2.5.7.4
CAVEATS
None.
2.5.8
Alignment of Objects
The __align(alignment) specifier may be used to indicate that variables must be
aligned on a memory address that is a multiple of the alignment specified. The alignment term must be a power of two. Positive values request that the object’s start
address be aligned; negative values imply the object’s end address be aligned.
Use the native keywords discussed in the Differences section to look up information on
the semantics of this specifier.
2.5.8.1
EXAMPLE
The following shows variables qualified using __align() to ensure they end on an
address that is a multiple of 8, and start on an address that is a multiple of 2,
respectively.
__align(-8) int spacer;
__align(2) char coeffs[6];
2.5.8.2
DIFFERENCES
An alignment feature has never been implemented on 8-bit compilers.
The 16- and 32-bit compilers used the aligned attribute with variables.
2.5.8.3
MIGRATION TO THE CCI
For 16- and 32-bit compilers, change any occurrence of the aligned attribute, as in
the following example:
char __attribute__((aligned(4)))mode;
to __align, i.e., __align(4) char mode;
2.5.8.4
CAVEATS
This feature is not yet implemented on XC8.
DS52053A-page 30
2012 Microchip Technology Inc.
Common C Interface
2.5.9
EEPROM Objects
The __eeprom qualifier may be used to indicate that variables should be positioned in
EEPROM.
Use the native keywords discussed in the Differences section to look up information on
the semantics of this qualifier.
Some devices may not implement EEPROM. Use of this qualifier for such devices will
generate a warning. Stack-based (auto and parameter) variables cannot use the
__eeprom specifier.
2.5.9.1
EXAMPLE
The following shows a variable qualified using __eeprom.
__eeprom int serialNos[4];
2.5.9.2
DIFFERENCES
The 8-bit compilers have used the qualifier, eeprom, to indicate this meaning for some
devices.
The 16-bit compilers have used the space attribute to allocate variables to the memory
space used for EEPROM.
2.5.9.3
MIGRATION TO THE CCI
For 8-bit compilers, change any occurrence of the eeprom qualifier, as in the following
example:
eeprom char title[20];
to __eeprom, i.e., __eeprom char title[20];
For 16-bit compilers, change any occurrence of the eedata space attribute, as in the
following
int mainSw __attribute__ ((space(eedata)));
to
int __eeprom mainSw;
2.5.9.4
CAVEATS
XC8 does not implement the __eeprom qualifiers for any PIC18 devices; this qualifier
will work as expected for other 8-bit devices.
2.5.10
Interrupt Functions
The __interrupt(type) specifier may be used to indicate that a function is to act
as an interrupt service routine. The type is a comma-separated list of keywords that
indicate information about the interrupt function.
The current interrupt types are:
Implement the default interrupt function
low_priority
The interrupt function corresponds to the low priority interrupt source (XC8 – PIC18
only)
high_priority
The interrupt function corresponds to the high priority interrupt source (XC8)
2012 Microchip Technology Inc.
DS52053A-page 31
MPLAB® XC8 C Compiler User’s Guide
save(symbol-list)
Save on entry and restore on exit the listed symbols (XC16)
irq(irqid)
Specify the interrupt vector associated with this interrupt (XC16)
altirq(altirqid)
Specify the alternate interrupt vector associated with this interrupt (XC16)
preprologue(asm)
Specify assembly code to be executed before any compiler-generated interrupt code
(XC16)
shadow
Allow the ISR to utilise the shadow registers for context switching (XC16)
auto_psv
The ISR will set the PSVPAG register and restore it on exit (XC16)
no_auto_psv
The ISR will not set the PSVPAG register (XC16)
Use the native keywords discussed in the Differences section to look up information on
the semantics of this specifier.
Some devices may not implement interrupts. Use of this qualifier for such devices will
generate a warning. If the argument to the __interrupt specifier does not make
sense for the target device, a warning or error will be issued by the compiler.
2.5.10.1
EXAMPLE
The following shows a function qualified using __interrupt.
__interrupt(low_priority) void getData(void) {
if (TMR0IE && TMR0IF) {
TMR0IF=0;
++tick_count;
}
}
2.5.10.2
DIFFERENCES
The 8-bit compilers have used the interrupt and low_priority qualifiers to indicate this meaning for some devices. Interrupt routines were by default high priority.
The 16- and 32-bit compilers have used the interrupt attribute to define interrupt
functions.
2.5.10.3
MIGRATION TO THE CCI
For 8-bit compilers, change any occurrence of the interrupt qualifier, as in the
following examples:
void interrupt myIsr(void)
void interrupt low_priority myLoIsr(void)
to the following, respectively
void __interrupt(high_priority) myIsr(void)
void __interrupt(low_priority) myLoIsr(void)
For 16-bit compilers, change any occurrence of the interrupt attribute, as in the following example:
void __attribute__((interrupt,auto_psv,(irq(52)))) myIsr(void);
DS52053A-page 32
2012 Microchip Technology Inc.
Common C Interface
to
void __interrupt(auto_psv,(irq(52)))) myIsr(void);
For 32-bit compilers, the __interrupt() keyword takes two parameters, the vector
number and the (optional) IPL value. Change code which uses the interrupt attribute, similar to these examples:
void __attribute__((vector(0), interrupt(IPL7AUTO), nomips16))
myisr0_7A(void) {}
void __attribute__((vector(1), interrupt(IPL6SRS), nomips16))
myisr1_6SRS(void) {}
/* Determine IPL and context-saving mode at runtime */
void __attribute__((vector(2), interrupt(), nomips16))
myisr2_RUNTIME(void) {}
to
void __interrupt(0,IPL7AUTO) myisr0_7A(void) {}
void __interrupt(1,IPL6SRS) myisr1_6SRS(void) {}
/* Determine IPL and context-saving mode at runtime */
void __interrupt(2) myisr2_RUNTIME(void) {}
2.5.10.4
CAVEATS
None.
2.5.11
Packing Objects
The __pack specifier may be used to indicate that structures should not use memory
gaps to align structure members, or that individual structure members should not be
aligned.
Use the native keywords discussed in the Differences section to look up information on
the semantics of this specifier.
Some compilers may not pad structures with alignment gaps for some devices and use
of this specifier for such devices will be ignored.
2.5.11.1
EXAMPLE
The following shows a structure qualified using __pack as well as a structure where
one member has been explicitly packed.
__pack struct DATAPOINT {
unsigned char type;
int value;
} x-point;
struct LINETYPE {
unsigned char type;
__pack int start;
long total;
} line;
2.5.11.2
DIFFERENCES
The __pack specifier is a new CCI specifier available with XC8. This specifier has no
apparent effect since the device memory is byte addressable for all data objects.
The 16- and 32-bit compilers have used the packed attribute to indicate that a structure member was not aligned with a memory gap.
2012 Microchip Technology Inc.
DS52053A-page 33
MPLAB® XC8 C Compiler User’s Guide
2.5.11.3
MIGRATION TO THE CCI
No migration is required for XC8.
For 16- and 32-bit compilers, change any occurrence of the packed attribute, as in the
following example:
struct DOT
{
char a;
int x[2] __attribute__ ((packed));
};
to:
struct DOT
{
char a;
__pack int x[2];
};
Alternatively, you may pack the entire structure, if required.
2.5.11.4
CAVEATS
None.
2.5.12
Indicating Antiquated Objects
The __deprecate specifier may be used to indicate that an object has limited longevity and should not be used in new designs. It is commonly used by the compiler vendor
to indicate that compiler extensions or features may become obsolete, or that better
features have been developed and which should be used in preference.
Use the native keywords discussed in the Differences section to look up information on
the semantics of this specifier.
2.5.12.1
EXAMPLE
The following shows a function which uses the __deprecate keyword.
void __deprecate getValue(int mode)
{
//...
}
2.5.12.2
DIFFERENCES
No deprecate feature was implemented on 8-bit compilers.
The 16- and 32-bit compilers have used the deprecated attribute (note different spelling) to indicate that objects should be avoided if possible.
2.5.12.3
MIGRATION TO THE CCI
For 16- and 32-bit compilers, change any occurrence of the deprecated attribute, as
in the following example:
int __attribute__(deprecated) intMask;
to:
int __deprecate intMask;
2.5.12.4
CAVEATS
None.
DS52053A-page 34
2012 Microchip Technology Inc.
Common C Interface
2.5.13
Assigning Objects to Sections
The __section() specifier may be used to indicate that an object should be located
in the named section (or psect, using the XC8 terminology). This is typically used when
the object has special and unique linking requirements which cannot be addressed by
existing compiler features.
Use the native keywords discussed in the Differences section to look up information on
the semantics of this specifier.
2.5.13.1
EXAMPLE
The following shows a variable which uses the __section keyword.
int __section("comSec") commonFlag;
2.5.13.2
DIFFERENCES
The 8-bit compilers have used the #pragma psect directive to redirect objects to a
new section, or psect. The operation of the __section() specifier is different to this
pragma in several ways, described below.
Unlike with the pragma, the new psect created with __section() does not inherit the
flags of the psect in which the object would normally have been allocated. This means
that the new psect can be linked in any memory area, including any data bank. The
compiler will also make no assumptions about the location of the object in the new section. Objects redirected to new psects using the pragma must always be linked in the
same memory area, albeit at any address in that area.
The __section() specifier allows objects that are initialized to be placed in a different
psect. Initialization of the object will still be performed even in the new psect. This will
require the automatic allocation of an additional psect (whose name will be the same
as the new psect prefixed with the letter i), which will contain the initial values. The
pragma cannot be used with objects that are initialized.
Objects allocated a different psect with __section() will be cleared by the runtime
startup code, unlike objects which use the pragma.
You must reserve memory, and locate via a linker option, for any new psect created with
a __section() specifier in the current XC8 compiler implementation.
The 16- and 32-bit compilers have used the section attribute to indicate a different
destination section name. The __section() specifier works in a similar way to the
attribute.
2.5.13.3
MIGRATION TO THE CCI
For XC8, change any occurrence of the #pragma psect directive, such as
#pragma psect text%%u=myText
int getMode(int target) {
//...
}
to the __section() specifier, as in
int __section ("myText") getMode(int target) {
//...
}
For 16- and 32-bit compilers, change any occurrence of the section attribute, as in
the following example:
int __attribute__((section("myVars"))) intMask;
to:
int __section("myVars") intMask;
2012 Microchip Technology Inc.
DS52053A-page 35
MPLAB® XC8 C Compiler User’s Guide
2.5.13.4
CAVEATS
With XC8, the __section() specifier cannot be used with any interrupt function.
2.5.14
Specifying Configuration Bits
The #pragma config directive may be used to program the configuration bits for a
device. The pragma has the form:
#pragma config setting = state|value
where setting is a configuration setting descriptor (e.g., WDT), state is a descriptive
value (e.g., ON) and value is a numerical value.
Use the native keywords discussed in the Differences section to look up information on
the semantics of this directive.
2.5.14.1
EXAMPLE
The following shows configuration bits being specified using this pragma.
#pragma config WDT=ON, WDTPS = 0x1A
2.5.14.2
DIFFERENCES
The 8-bit compilers have used the __CONFIG() macro for some targets that did not
already have support for the #pragma config.
The 16-bit compilers have used a number of macros to specify the configuration settings.
The 32-bit compilers supported the use of #pragma config.
2.5.14.3
MIGRATION TO THE CCI
For the 8-bit compilers, change any occurrence of the __CONFIG() macro, such as
__CONFIG(WDTEN & XT & DPROT)
to the #pragma config directive, as in
#pragma config WDTE=ON, FOSC=XT, CPD=ON
No migration is required if the #pragma config was already used.
For the 16-bit compilers, change any occurrence of the _FOSC() or _FBORPOR()
macros attribute, as in the following example:
_FOSC(CSW_FSCM_ON & EC_PLL16);
to:
#pragma config FCKSMEM = CSW_ON_FSCM_ON,
FPR = ECIO_PLL16
No migration is required for 32-bit code.
2.5.14.4
CAVEATS
None.
2.5.15
Manifest Macros
The CCI defines the general form for macros that manifest the compiler and target
device characteristics. These macros can be used to conditionally compile alternate
source code based on the compiler or the target device.
The macros and macro families are details in Table 2-1.
TABLE 2-1:
Name
__XC__
DS52053A-page 36
MANIFEST MACROS DEFINED BY THE CCI
Meaning if defined
Example
Compiled with an MPLAB XC compiler
__XC__
2012 Microchip Technology Inc.
Common C Interface
TABLE 2-1:
MANIFEST MACROS DEFINED BY THE CCI
Name
Meaning if defined
Example
__CCI__
Compiler is CCI compliant and CCI enforcement is enabled
__CCI__
__XC##__
The specific XC compiler used (## can be 8,
16 or 32)
__XC8__
__DEVICEFAMILY__
__DEVICENAME__
2.5.15.1
The family of the selected target device
The selected target device name
__dsPIC30F__
__18F452__
EXAMPLE
The following shows code which is conditionally compiled dependent on the device
having EEPROM memory.
#ifdef __XC16__
void __interrupt(__auto_psv__) myIsr(void)
#else
void __interrupt(low_priority) myIsr(void)
#endif
2.5.15.2
DIFFERENCES
Some of these CCI macros are new (for example __CCI__), and others have different
names to previous symbols with identical meaning (for example __18F452 is now
__18F452__).
2.5.15.3
MIGRATION TO THE CCI
Any code which uses compiler-defined macros will need review. Old macros will continue to work as expected, but they are not compliant with the CCI.
2.5.15.4
CAVEATS
None.
2012 Microchip Technology Inc.
DS52053A-page 37
MPLAB® XC8 C Compiler User’s Guide
2.5.16
In-line Assembly
The asm() statement may be used to insert assembly code in-line with C code. The
argument is a C string literal which represents a single assembly instruction. Obviously,
the instructions contained in the argument are device specific.
Use the native keywords discussed in the Differences section to look up information on
the semantics of this statement.
2.5.16.1
EXAMPLE
The following shows a MOVLW instruction being inserted in-line.
asm("MOVLW _foobar");
2.5.16.2
DIFFERENCES
The 8-bit compilers have used either the asm() or #asm ... #endasm constructs to
insert in-line assembly code.
This is the same syntax used by the 16- and 32-bit compilers.
2.5.16.3
MIGRATION TO THE CCI
For 8-bit compilers change any instance of #asm ... #endasm so that each instruction
in this #asm block is placed in its own asm() statement, for example:
#asm
MOVLW 20
MOVWF _i
CLRF
Ii+1
#endasm
to
asm("MOVLW20");
asm("MOVWF _i");
asm("CLRFIi+1");
No migration is required for the 16- or 32-bit compilers.
2.5.16.4
CAVEATS
None.
DS52053A-page 38
2012 Microchip Technology Inc.
Common C Interface
2.6
COMPILER FEATURES
The following items detail compiler options and features that are not directly associated
with source code that
2.6.1
Enabling the CCI
It is assumed you are using the MPLAB X IDE to build projects that use the CCI. The
widget in the MPLAB X IDE Project Properties to enable CCI conformance is Use CCI
Syntax in the Compiler category. A widget with the same name is available in MPLAB
IDE v8 under the Compiler tab.
If you are not using this IDE, then the command-line options are --CCI for XC8 or
-mcci for XC16/32.
2.6.1.1
DIFFERENCES
This option has never been implemented previously.
2.6.1.2
MIGRATION TO THE CCI
Enable the option.
2.6.1.3
CAVEATS
None.
2012 Microchip Technology Inc.
DS52053A-page 39
MPLAB® XC8 C Compiler User’s Guide
NOTES:
DS52053A-page 40
2012 Microchip Technology Inc.
MPLAB® XC8 C COMPILER
USER’S GUIDE
Chapter 3. How To’s
3.1
INTRODUCTION
This section contains help and references for situations that are frequently encountered
when building projects for Microchip 8-bit devices. Click the links at the beginning of
each section to assist finding the topic relevant to your question. Some topics are
indexed in multiple sections.
Start here:
•
•
•
•
•
•
3.2
Installing and Activating the Compiler
Invoking the Compiler
Writing Source Code
Getting My Application to Do What I Want
Understanding the Compilation Process
Fixing Code That Does Not Work
INSTALLING AND ACTIVATING THE COMPILER
This section details questions that might arise when installing or activating the compiler.
• How Do I Install and Activate My Compiler?
• How Can I Tell if the Compiler has Activated Successfully?
• Can I Install More Than One Version of the Same Compiler?
3.2.1
How Do I Install and Activate My Compiler?
Installation and activation of the license are performed simultaneously by the XC compiler installer. The guide Installing and Licensing MPLAB XC C Compilers (DS52059)
is available on www.microchip.com. It provides details on single-user and network
licenses, as well as how to activate a compiler for evaluation purposes.
3.2.2
How Can I Tell if the Compiler has Activated Successfully?
If you think the compiler may not have installed correctly or is not working, it is best to
verify its operation outside of MPLAB IDE to isolate possible problems. Try running the
compiler from the command line to check for correct operation. You do not actually
have to compile code.
From your terminal or DOS-prompt, run the compiler driver xc8 (see Section 4.2
“Invoking the Compiler”) with the option --VER. This option instructs the compiler to
print version information and exit. So, under Windows, for example, type the following
line, replacing the path information with a path that is relevant to your installation.
"C:\Program Files\Microchip\xc8\v1.00\bin\xc8" --ver
The compiler should run, print an informative banner and quit. That banner indicates
the operating mode. Confirm that the operating mode is the one you requested. Note:
if it is not activated properly, the compiler will continue to operate, but only in the Free
mode. If an error is displayed, or the compiler indicates Free mode, then activation was
not successful.
2012 Microchip Technology Inc.
DS52053B-page 41
MPLAB® XC8 C Compiler User’s Guide
3.2.3
Can I Install More Than One Version of the Same Compiler?
Yes, the compilers and installation process has been designed to allow you to have
more than one version of the same compiler installed, and you can easily swap
between version by changing options in MPLAB IDE, see Section 3.3.4 “How Can I
Select Which Compiler I Want to Build With?”.
Compilers should be installed into a directory whose name is related to the compiler
version. This is reflected in the default directory specified by the installer. For example,
the 1.00 and 1.10 XC8 compilers would typically be placed in separate directories.
C:\Program Files\Microchip\xc8\v1.00\
C:\Program Files\Microchip\xc8\v1.10\
DS52053B-page 42
2012 Microchip Technology Inc.
How To’s
3.3
INVOKING THE COMPILER
This section discusses how the compiler is run, both on the command-line and from the
MPLAB IDE. It includes information about how to get the compiler to do what you want
in terms of options and the build process itself.
•
•
•
•
•
•
•
•
•
•
•
•
•
How Do I Compile from Within MPLAB X IDE?
How Do I Compile on the Command-line?
How Do I Compile Using a Make Utility?
How Can I Select Which Compiler I Want to Build With?
How Can I Change the Compiler's Operating Mode?
What Do I Need to Do When Compiling to Use a Debugger?
How Do I Build Libraries?
How Do I Use Library Files In My Project?
How Do I Know What Compiler Options Are Available and What They Do?
How Do I Know What the Build Options in MPLAB IDE do?
What is Different About an MPLAB IDE Debug Build?
How Do I Stop the Compiler Using Certain Memory Locations?
What Optimizations Are Employed By The Compiler?
3.3.1
How Do I Compile from Within MPLAB X IDE?
See the documentation that comes with MPLAB X IDE for information on how to set up
a project.
If you have one or more XC8 compilers installed, you select the compiler you wish to
use in the Configuration category in the Project Properties dialog. The options for that
compiler are then shown in the XC8 Compiler and XC8 Linker categories. Note that
each of these compiler categories have several Option categories.
3.3.2
How Do I Compile on the Command-line?
The compiler driver is called xc8 for all 8-bit PIC devices; e.g., in Windows, it is named
xc8.exe. This application should be invoked for all aspects of compilation. It is located
in the bin directory of the compiler distribution. Avoid running the individual compiler
applications (such as the assembler or linker) explicitly. You can compile and link in the
one command, even if your project is spread among multiple source files.
The driver is introduced in Section 4.2 “Invoking the Compiler”. See 3.3.4 How Can
I Select Which Compiler I Want to Build With? to ensure you are running the correct
driver if you have more than one installed. The command-line options to the driver are
detailed in Section 4.7 “XC8 Driver Options”. The files that can be passed to the
driver are listed and described in Section 4.2.3 “Input File Types”.
3.3.3
How Do I Compile Using a Make Utility?
When compiling using a make utility (such as make), the compilation is usually performed as a two-step process: first generating the intermediate files, then the final compilation and link step to produce one binary output. This is described in Section 4.3.3
“Multi-Step Compilation”.
The XC8 compiler uses a unique technology called OCG which uses a different intermediate file format to traditional compilers (including XC16 and XC32)The intermediate
file format used by XC8 is a p-code file (.p1 extension), not an object file. Generating
object files as an intermediate file for multi-step compilation will defeat many of the
advantages of this technology.
2012 Microchip Technology Inc.
DS52053B-page 43
MPLAB® XC8 C Compiler User’s Guide
3.3.4
How Can I Select Which Compiler I Want to Build With?
The compilation and installation process has been designed to allow you to have more
than one compiler installed at the same time. You can create a project in MPLAB X IDE
and then build this project with different compilers by simply changing a setting in the
project properties.
To select which compiler is actually used when building a project under MPLAB X IDE,
go to the Project properties dialog. Select the Configuration category in the Project
Properties dialog (Conf: [default]). A list of XC8 compilers is shown in the Compiler Toolchain, on the far right. Select the XC8 compiler you require.
Once selected, the controls for that compiler are then shown by selecting the XC8
global options, XC8 Compiler and XC8 Linker categories. These reveal a pane of
options on the right. Note that each category has several panes which can be selected
from a pull-down menu that is near the top of the pane.
3.3.5
How Can I Change the Compiler's Operating Mode?
The compiler’s operating mode (Free, Standard or PRO, see Section 1.2 “Compiler
Description and Documentation”) can be specified as a command line option when
building on the command line, see Section 4.8.37 “--MODE: Choose Compiler Operating Mode”. If you are building under MPLAB X IDE, there is a Project Properties
selector in the XC8 compiler category, under the Optimizations option selector, see
Section 4.10.2 “Compiler Category”.
You can only select modes that your license entitles you to use. The Free mode is
always available; Standard or PRO can be selected if you have purchased a license for
those modes.
3.3.6
How Do I Build Libraries?
Note that XC8 uses a different code generation framework (OCG) which uses additional library files to those used by traditional compilers (including XC16 and XC32).
See Section 4.3.1 “The Compiler Applications” for general information on the library
types available and how they fit into the compilation process.
When you have functions and data that are commonly used in applications, you can
either make all the C source and header files available so other developers can copy
these into their projects. Alternatively you can bundle these source files up into a library
which, along with the accompanying header files, can be linked into a project.
Libraries are more convenient because there are fewer files to deal with. Compiling
code from a library is also be fractionally faster. However, libraries do need to be maintained. XC8 must use LPP libraries for library routines written in C; the old-style LIB
libraries are used for library routines written in assembly source. It is recommended
that even these libraries be rebuilt if your project is moving to a new compiler version.
Using the compiler driver, libraries can be built by listing all the files that are to be
included into the library on the command line. None of these files should contain a
main() function, nor settings for configuration bits or any other such data. Use the
--OUTPUT=lpp option, see Section 4.8.44 “--OUTPUT= type: Specify Output File
Type” to indicate that a library file is required. For example:
XC8 --chip=16f877a --output=lpp lcd.c utils.c io.c
creates a library file called lcd.lpp. You can specify another name using the -O
option, see Section 4.8.10 “-O: Specify Output File” or just rename the file.
DS52053B-page 44
2012 Microchip Technology Inc.
How To’s
3.3.7
How Do I Know What Compiler Options Are Available and What
They Do?
A list of all compiler options can be obtained by using the --HELP option on the command line, see Section 4.8.33 “--HELP: Display Help”. If you give the --HELP option
an argument, being an option name, it will give specific information on that option.
Alternatively, all options are all listed in Section 4.8 “Option Descriptions” in this
user’s guide. If you are compiling in MPLAB X IDE, see Section 4.10 “MPLAB X Universal Toolsuite Equivalents”, or in MPLAB IDE version 8, see Section 4.9 “MPLAB
IDE V8 Universal Toolsuite Equivalents”.
3.3.8
How Do I Know What the Build Options in MPLAB IDE do?
The widgets and controls in the MPLAB IDE Build options in most instances map
directly to one command-line driver option or suboption. The section in the user’s guide
that lists all command-line driver options (Section 4.8 “Option Descriptions”) has
cross references, where appropriate, to the corresponding section which relates to
accessing that option from the IDE. There are two separate sections for MPLAB X IDE
(Section 4.10 “MPLAB X Universal Toolsuite Equivalents”) and MPLAB IDE version 8 (Section 4.9 “MPLAB IDE V8 Universal Toolsuite Equivalents”).
3.3.9
What is Different About an MPLAB IDE Debug Build?
The Debug/Release pull-down widget in the MPLAB IDE version 8 toolbar indicates
whether the build should be a debug or release build. In MPLAB X, there are separate
build buttons and menu items to build a project and debug a project.
There are many differences in terms of the IDE, but for the XC8 compiler, there is very
little that is different between the two. The main difference is the setting of a preprocessor macro called __DEBUG to be 1 when a debug is selected. This macro is not defined
if it is not a debug build.
You may make code in your source conditional on this macro using #ifdef directives,
etc (see Section 5.14.2 “Preprocessor Directives”) so that you can have your program behave differently when you are still in a development cycle. Some compiler
errors are easier to track down after performing a debug build.
In MPLAB X IDE, memory will be reserved for your debugger (if selected) only when
you perform a debug build. In MPLAB v8, memory is always reserved if you select a
debugger hardware tool in your project, see Section 3.5.3 “What Do I Need to Do
When Compiling to Use a Debugger?”.
2012 Microchip Technology Inc.
DS52053B-page 45
MPLAB® XC8 C Compiler User’s Guide
3.4
WRITING SOURCE CODE
This section presents issues pertaining to the source code you write. It has been
subdivided into sections listed below.
•
•
•
•
•
•
•
C Language Specifics
Device-Specific Features
Memory Allocation
Variables
Functions
Interrupts
Assembly Code
3.4.1
C Language Specifics
This section discusses source code issues that are directly relates to the C language
itself but which are commonly asked.
•
•
•
•
When Should I Cast Expressions?
Can Implicit Type Conversions Change the Expected Results of My Expressions?
How Do I Enter Non-english Characters Into My Program?
How Can I Use a Variable Defined in Another Source File?
3.4.1.1
WHEN SHOULD I CAST EXPRESSIONS?
Expressions can be explicitly case using the cast operator -- a type in round brackets,
e.g., (int). In all cases, conversion of one type to another must be done with caution
and only when absolutely necessary.
Consider the example:
unsigned long l;
unsigned int i;
i = l;
Here, a long type is being assigned to a int type, and the assignment will truncate
the value in l. The compiler will automatically perform a type conversion from the type
of the expression on the right of the assignment operator (long) to the type of the
lvalue on the left of the operator (int).This is called an implicit type conversion. The
compiler will typically produce a warning concerning the potential loss of data by the
truncation.
A cast to type int is not required and should not be used in the above example if a
long to int conversion was intended. The compiler knows the types of both operands
and will perform the conversion accordingly. If you did use a cast, there is the potential
for mistakes if the code is later changed. For example, if you had:
i = (int)l;
the code will work the in the same way; but, if in future, the type of i is changed to a
long, for example, then you must remember to adjust the cast, or remove it, otherwise
the contents of l will continue to be truncated by the assignment, which may not be
correct. Most importantly, the warning issued by the compiler will not be produced if the
cast is in place.
DS52053B-page 46
2012 Microchip Technology Inc.
How To’s
Only use a cast in situations where the types used by the compiler are not the types
that you require. For example consider the result of a division assigned to a floating
point variable:
int i, j;
float fl;
fl = i/j;
In this case integer division is performed, then the rounded integer result is converted
to a float format. So if i contained 7 and j contained 2, the division will yield 3 and
this will be implicitly converted to a float type (3.0) and then assigned to fl. If you
wanted the division to be performed in a float format, then a cast is necessary:
fl = (float)i/j;
(Casting either i or j will force the compiler to encode a floating-point division). The
result assigned to fl now be 3.5.
An explicit cast may suppress warnings that might otherwise have been produced. This
can also be the source of many problems. The more warnings the compiler produces,
the better chance you have of finding potential bugs in your code.
3.4.1.2
CAN IMPLICIT TYPE CONVERSIONS CHANGE THE EXPECTED
RESULTS OF MY EXPRESSIONS?
Yes! The compiler will always use integral promotion and there is no way to disable this,
see Section 5.6.1 “Integral Promotion”. In addition, the types of operands to binary
operators are usually changed so that they have a common type as specified by the C
Standard. Changing the type of an operand can change the value of the final expression so it is very important that you understand the type C Standard conversion rules
that apply when dealing with binary operators. You can manually change the type of an
operand by casting, see Section 3.4.1.1 “When Should I Cast Expressions?”.
3.4.1.3
HOW DO I ENTER NON-ENGLISH CHARACTERS INTO MY PROGRAM?
The ANSI standard and MPLAB XC8 do not support extended characters set in character and string literals in the source character set. See Section 5.4.6 “Constant
Types and Formats” to see how these characters can be entered using escape
sequences.
3.4.1.4
HOW CAN I USE A VARIABLE DEFINED IN ANOTHER SOURCE FILE?
Provided the variable defined in the other source file is not static (see
Section 5.5.2.1.1 “Static Variables”) or auto (see Section 5.5.2.2 “Auto Variable
Allocation and access”), then adding a declaration for that variable in the current file
will allow you to access it. A declaration consists of the keyword extern in addition to
the type and name of the variable as specified in its definition, e.g.
extern int systemStatus;
This is part of the C language and your favorite C text will give you more information.
The position of the declaration in the current file determines the scope of the variable,
i.e., if you place the declaration inside a function, it will limit the scope of the variable to
that function; placed outside of a function allows access to the variable in all functions
for the remainder of the current file.
Often, declarations are placed in header files and these are then #included into the
C source code, see Section 5.14.2 “Preprocessor Directives”.
2012 Microchip Technology Inc.
DS52053B-page 47
MPLAB® XC8 C Compiler User’s Guide
3.4.2
Device-Specific Features
This section discusses the code that needs to be written to set up or control a feature
that is specific to Microchip PIC devices.
•
•
•
•
•
•
How Do I Set the Configuration Bits?
How Do I Use the PIC’s ID Locations?
How Do I Determine the Cause of Reset on Mid-range Parts?
How Do I Access SFRs?
How Do I Stop the Compiler Using Certain Memory Locations?
What Do I Need to Do When Compiling to Use a Debugger?
3.4.2.1
HOW DO I SET THE CONFIGURATION BITS?
These should be set in your code using either a macro or pragma. Earlier versions of
MPLAB IDE allowed you to set these bits in a dialog, but MPLAB X IDE requires that
they be specified in your source code. See Section 5.3.5 “Configuration Bit Access”
for how these are set.
3.4.2.2
HOW DO I USE THE PIC’S ID LOCATIONS?
There is a supplied macro or pragma that allows these values to be programmed, see
Section 5.3.7 “ID Locations”.
3.4.2.3
HOW DO I DETERMINE THE CAUSE OF RESET ON MID-RANGE
PARTS?
The TO and PD bits in the STATUS register allow you to determine the cause of a
Reset. However, these bits are quickly overwritten by the runtime startup code that is
executed before main is executed, see Section 5.10.1 “Runtime Startup Code”. You
can have the STATUS register saved into a location that is later accessible from C code
so that the cause of Reset can be determined by the application once it is running
again. See Section 5.10.1.4 “STATUS Register Preservation”.
3.4.2.4
HOW DO I ACCESS SFRS?
The compiler ships with header files, see Section 5.3.3 “Device Header Files”, that
define variables which are mapped over the top of memory-mapped SFRs. Since these
are C variables, they can be used like any other C variable and no new syntax is
required to access these registers.
Bits within SFRs can also be accessed. Individual bit-wide variables are defined which
are mapped over the bits in the SFR. Bit-fields are also available in structures which
map over the SFR as a whole. You can use either in your code. See Section 5.3.6
“Using SFRs From C Code”.
The name assigned to the variable is usually the same as the name specified in the
device data sheet. See Section 3.4.2.5 “How Do I Find The Names Used to Represent SFRs and Bits?” if these names are not recognized.
DS52053B-page 48
2012 Microchip Technology Inc.
How To’s
3.4.2.5
HOW DO I FIND THE NAMES USED TO REPRESENT SFRS AND BITS?
Special function registers and the bits within those are accessed via special variables
that map over the register, Section 3.4.2.4 “How Do I Access SFRs?”; however, the
names of these variables sometimes differ from those indicated in the data sheet for
the device you are using.
You can work your way through the header file to find the device-specific
header file which allows access to these special variables, but an easier way is to look
in any of the preprocessed files left behind after a previous compilation. These file have
a .pre extension and there will be one file with the same base name as each source
file in your project. Look in the preprocessed file for any source file that include
as this will include the definition for all the SFR variables and bits within those.
If you are compiling under MPLAB X IDE, the preprocessed file(s) are left under the
build/default/production directory of your project for regular builds, or under
build/default/debug for debug builds. The are typically left in the source file directory if you are compiling on the command line.
3.4.3
Memory Allocation
Here are questions relating to how your source code affects memory allocation.
•
•
•
•
•
How Do I Position Variables at an Address I Nominate?
How Do I Position Functions at an Address I Nominate?
How Do I Place Variables in Program Memory?
How Do I Stop the Compiler Using Certain Memory Locations?
Why are some objects positioned into memory that I reserved?
3.4.3.1
HOW DO I POSITION VARIABLES AT AN ADDRESS I NOMINATE?
The easiest way to do this is to make the variable absolute, by using the @ address
construct, see Section 5.5.4 “Absolute Variables”. This means that the address you
specify is used in preference to the variable’s symbol in generated code. Since you
nominate the address, you have full control over where objects are positioned, but you
must also ensure that absolute variables do not overlap. Variables placed in the middle
of banks can cause havoc with the allocation of other variables and lead to "Can’t find
space" errors, see Section 3.7.6 “How Do I Fix a "Can’t find space..." Error?”. See
also Section 5.5.2.4 “Changing the Default Auto Variable Allocation” for information on moving auto variables, Section 5.5.2.1.3 “Changing the Default Non-Auto
Variable Allocation” for moving non-auto variables and Section 5.5.3.2 “Changing
the Default Allocation” for moving program-space variables.
3.4.3.2
HOW DO I POSITION FUNCTIONS AT AN ADDRESS I NOMINATE?
The easiest way to do this is to make the functions absolute, by using the @ address
construct, see Section 5.8.4 “Changing the Default Function Allocation”. This
means that the address you specify is used in preference to the variable’s symbol in
generated code. Since you nominate the address, you have full control over where
functions are positioned, but must also ensure that absolute functions do not overlap.
Functions placed in the middle of pages can cause havoc with the allocation of other
functions and lead to "Can’t find space" errors, see Section 3.7.6 “How Do I Fix a
"Can’t find space..." Error?”.
2012 Microchip Technology Inc.
DS52053B-page 49
MPLAB® XC8 C Compiler User’s Guide
3.4.3.3
HOW DO I PLACE VARIABLES IN PROGRAM MEMORY?
The const qualifier implies that the qualified variable is read only. As a consequence
of this, any variables (except for auto variables or function parameters) qualified const
are placed in program memory, thus freeing valuable data RAM, see Section 5.5.3
“Variables in Program Space”. Variables qualified const can also be made absolute,
so that they can be positioned at an address you nominate, see Section 5.5.4.2
“Absolute Objects in Program Memory”.
3.4.3.4
HOW DO I STOP THE COMPILER USING CERTAIN MEMORY
LOCATIONS?
Memory can be reserved when you build. The --RAM and --ROM options allow you to
adjust the ranges of data and program memory, respectively, when you build. See
Section 4.8.48 “--RAM: Adjust RAM Ranges” and Section 4.8.49 “--ROM: Adjust
ROM Ranges”. By default, all the available on-chip memory is available for use, but
these options allow you to reserve parts of this memory.
3.4.4
Variables
This examines questions that relate to the definition and usage of variables and types
within a program.
•
•
•
•
•
•
•
•
•
•
•
Why Are My Floating-point Results Not Quite What I Am Expecting?
How Can I Access Individual Bits of a Variable?
How Long Can I Make My Variable and Macro Names?
How Do I Share Data Between Interrupt and Main-line Code?
How Do I Position Variables at an Address I Nominate?
How Do I Place Variables in Program Memory?
How Do I Place Variables in The PIC18’s External Program Memory?
How Can I Rotate a Variable?
How Do I Utilize All the RAM Banks on My Device?
How Do I Utilize the Linear Memory on Enhanced Mid-range PIC Devices?
How Do I Find Out Where Variables and Functions Have Been Positioned?
3.4.4.1
WHY ARE MY FLOATING-POINT RESULTS NOT QUITE WHAT I AM
EXPECTING?
First, make sure that if you are watching floating-point variables in MPLAB IDE that the
type and size of these match how they are defined. For 24-bit floating point variables
(whether they have type float or double) ensure that the Format in the variable
properties is set to IEEE float MPLAB IDE v8. In MPLAB X IDE set the Display Column
Value As popup menu to IEEE float (24 bit). If the variable is a 32-bit floating point
object, set the types to IEEE Float in both IDEs.
The size of the floating point type can be adjusted for both float and double types,
see Section 4.8.31 “--FLOAT: Select Kind of Float Types” and Section 4.8.24
“--DOUBLE: Select Kind of Double Types”.
Since floating-point variables only have a finite number of bits to represent the values
they are assigned, they will hold an approximation of their assigned value, see
Section 5.4.3 “Floating-Point Data Types”. A floating-point variable can only hold
one of a set of discrete real number values. If you attempt to assign a value that is not
in this set, it is rounded to the nearest value. The more bits used by the mantissa in the
floating-point variable, the more values can be exactly represented in the set and the
average error due to the rounding is reduced.
Whenever floating-point arithmetic is performed, rounding also occurs. This can also
lead to results that do not appear to be correct.
DS52053B-page 50
2012 Microchip Technology Inc.
How To’s
3.4.4.2
HOW CAN I ACCESS INDIVIDUAL BITS OF A VARIABLE?
There are several ways of doing this. The simplest and most portable way is to define
an integer variable and use macros to read, set or clear the bits within the variable
using a mask value and logical operations, such as the following.
#define
#define
#define
testbit(var, bit)
setbit(var, bit)
clrbit(var, bit)
((var) & (1 task.timer_count(BANK0[2]),
The pointer reference graph shows both pointers to data objects and pointers to
functions.
DS52053B-page 272
2012 Microchip Technology Inc.
Macro Assembler
6.6.6
Call Graph
The other important information block in the assembly list file is the call graph (look for
Call Graph Tables: in the list file). This is produced for target devices that use a compiled stack to facilitate local variables, such as function parameters and auto variables.
See Section 5.5.2.2.1 “Compiled Stack Operation” for more detailed information on
compiled stack operation.
The call graph in the list file shows the information collated and interpreted by the code
generator, which is primarily used to allow overlapping of functions’ auto-parameter
blocks (APBs). The following information can be obtained from studying the call graph.
• The functions in the program that are “root” nodes marking the top of a call tree,
and which are called spontaneously
• The functions that the linker deemed were called, or may have been called, during
program execution
• The program’s hierarchy of function calls
• The size of the auto and parameter areas within each function’s APB
• The offset of each function’s APB within the compiled stack
• The estimated call tree depth.
6.6.6.1
These features are discussed below.
A typical call graph may look that shown inFigure 6-4.
FIGURE 6-4:
CALL GRAPH FORM
Call Graph Tables:
--------------------------------------------------------------------------------(Depth) Function
Calls
Base Space
Used Autos Params
Refs
--------------------------------------------------------------------------------(0) _main
12
12
0
34134
43 BANK0
5
5
0
0 BANK1
7
7
0
_aOut
_initSPI
--------------------------------------------------------------------------------(1) _aOut
2
0
2
68
2 BANK0
2
0
2
_SPI
_GetDACValue (ARG)
--------------------------------------------------------------------------------(1) _initSPI
0
0
0
0
--------------------------------------------------------------------------------(2) _SPI
2
2
0
23
0 BANK0
2
2
0
...
Estimated maximum stack depth 6
---------------------------------------------------------------------------------
The graph starts with the function main(). Note that the function name will always be
shown in the assembly form, thus the function main() appears as the symbol _main.
main() is always a root of a call tree. Interrupt functions will form separate trees.
2012 Microchip Technology Inc.
DS52053B-page 273
MPLAB® XC8 C Compiler User’s Guide
All the functions that main() calls, or may call, are shown below. These have been
grouped in the orange box in the figure. A function’s inclusion into the call graph does
not imply the function was actually called, but there is a possibility that the function was
called. For example, code such as:
int test(int a) {
if(a)
foo();
else
bar();
}
will list foo() and bar() under test(), as either may be called. If a is always true,
then the function bar() will never be called even though it appears in the call graph.
In addition to these functions there is information relating to the memory allocated in
the compiled stack for main(). This memory will be used for auto, temporary and
parameter variables defined in main(). The only difference between an auto and
temporary variable is that auto variables are defined by the programmer, and
temporaries are defined by the compiler, but both behave in the same way.
In the orange box for main() you can see that it defines 10 auto and temporary variable. It defines no parameters (main() never has parameters). There is a total of 24
references in the assembly code to local objects in main().
Rather than the compiled stack being one memory allocation in one memory space, it
can have components placed in multiple memory spaces to utilize all available memory
of the target device. This break down is shown under the memory summary line for
each function. In this example, it shows that some of the local objects for main() are
placed in the common memory, but others are placed in bank 0 data RAM.
The Used column indicates how many bytes of memory are used by each section of
the compiled stack and the Space column indicates in which space that has been
placed. The Base value indicates the offset that block has in the respective section of
the compiled stack. For example, the figure tells us main()has 6 bytes of memory allocated at an offset of 4 in the compiled stack section that lives in common memory. It
also has 4 bytes of memory allocated in bank 0 memory at an offset of 16 in the bank
0 compiled stack component.
Below the information for main() (outside the orange box) you will see the same information repeated for the functions that main() called, i.e., rv(), rvx() and rvy().
Indentation is used to indicate the maximum depth that function reaches in the call
graph. The arrows in the figure highlight this indentation.
After each tree in the call graph, there is an indication of the maximum call (stack) depth
that might be realized by that tree. This may be used as a guide to the stack usage of
the program. No definitive value can be given for the program’s total stack usage for
several reasons:
• Certain parts of the call tree may never be reached, reducing that tree’s stack
usage.
• The contribution of interrupt (or other) trees to the main() tree cannot be determined as the point in main’s call tree at which the interrupt (or other function
invocation) will occur cannot be known;
• The assembler optimizer may have replaced function calls with jumps to
functions, reducing that tree’s stack usage.
• The assembler’s procedural abstraction optimizations may have added in calls to
abstracted routines. (Checks are made to ensure this does not exceed the
maximum stack depth.)
DS52053B-page 274
2012 Microchip Technology Inc.
Macro Assembler
The code generator also produces a warning if the maximum stack depth appears to
have been exceeded. For the above reasons, this warning, too, is intended to be a only
a guide to potential stack problems.
6.6.6.2
CALL GRAPH CRITICAL PATHS
Immediately prior to the call graph tables in the list file are the critical paths for memory
usage identified in the call graphs. A critical path is printed for each memory space and
for each call graph. Look for a line similar to Critical Paths under _main in BANK0,
which, for this example, indicates the critical path for the main function (the root of one
call graph) in bank 0 memory. There will be one call graph for the function main and
another for each interrupt function, and each of these will appear for every memory
space the device defines.
A critical path here represents the biggest range of APBs stacked together in as a contiguous block. Essentially, it identifies those functions whose APBs are contributing to
the program’s memory usage in that particular memory space. If you can reduce the
memory usage of these functions in the corresponding memory space, then you will
affects the program’s total memory usage in that memory space.
This information may be presented as follows.
3793
3794
3795
3796
3797
;; Critical Paths under _main in BANK0
;;
;;
_main->_foobar
;;
_foobar->___flsub
;;
___flsub->___fladd
In this example, it shows that of all the call graph paths starting from the function main,
the path in which main calls foobar, which calls flsub, which calls fladd, is using
the largest block of memory in bank 0 RAM. The exact memory usage of each function
is shown in the call graph tables.
The memory used by functions that are not in the critical path will overlap entirely with
that in the critical path. Reducing the memory usage of these will have no impact on
the memory usage of the entire program.
2012 Microchip Technology Inc.
DS52053B-page 275
MPLAB® XC8 C Compiler User’s Guide
NOTES:
DS52053B-page 276
2012 Microchip Technology Inc.
MPLAB® XC8 C COMPILER
USER’S GUIDE
Chapter 7. Linker
7.1
INTRODUCTION
This chapter describes the theory behind, and the usage of, the linker.
The application name of the linker is HLINK. In most instances it will not be necessary
to invoke the linker directly, as the compiler driver, xc8, will automatically execute the
linker with all necessary arguments. Using the linker directly is not simple, and should
be attempted only by those with a sound knowledge of the compiler and linking in general. The compiler often makes assumptions about the way in which the program will
be linked. If the psects are not linked correctly, code failure may result.
If it is absolutely necessary to use the linker directly, the best way to start is to copy the
linker arguments constructed by the compiler driver, and modify them as appropriate.
This will ensure that the necessary startup module and arguments are present.
The following topics are examined in this chapter of the MPLAB XC8 C Compiler User’s
Guide:
• Operation
• Relocation and Psects
• Map Files
7.2
OPERATION
A command to the linker takes the following form:
hlink [options] files
The options are zero or more linker options, each of which modifies the behavior of
the linker in some way. The files is one or more object files, and zero or more object
code library names (.lib extension). P-code libraries (.lpp extension) are always
passed to the code generator application and cannot be passed to the linker.
The options recognized by the linker are listed in Table 7-1 and discussed in the
following paragraphs.
TABLE 7-1:
LINKER COMMAND-LINE OPTIONS
Option
Effect
-8
Use 8086 style segment:offset address form
-Aclass=low-high ,...
Specify address ranges for a class
-Cx
Call graph options
-Cpsect=class
Specify a class name for a global psect
-Cbaseaddr
Produce binary output file based at baseaddr
-Dclass=delta
Specify a class delta value
-Dsymfile
Produce old-style symbol file
-Eerrfile
Write error messages to errfile
-F
Produce .obj file with only symbol records
-G spec
Specify calculation for segment selectors
-H symfile
Generate symbol file
-H+ symfile
Generate enhanced symbol file
2012 Microchip Technology Inc.
DS52053B-page 277
MPLAB® XC8 C Compiler User’s Guide
TABLE 7-1:
LINKER COMMAND-LINE OPTIONS (CONTINUED)
Option
Effect
-I
Ignore undefined symbols
-J num
Set maximum number of errors before aborting
-K
Prevent overlaying function parameter and auto areas
-L
Preserve relocation items in .obj file
-LM
Preserve segment relocation items in .obj file
-N
Sort symbol table in map file by address order
-Nc
Sort symbol table in map file by class address order
-Ns
Sort symbol table in map file by space address order
-Mmapfile
Generate a link map in the named file
-Ooutfile
Specify name of output file
-Pspec
Specify psect addresses and ordering
-Qprocessor
Specify the device type (for cosmetic reasons only)
-S
Inhibit listing of symbols in symbol file
-Sclass=limit[,bound]
Specify address limit, and start boundary for a class of
psects
-Usymbol
Pre-enter symbol in table as undefined
-Vavmap
Use file avmap to generate an Avocet format symbol file
-Wwarnlev
Set warning level (-9 to 9)
-Wwidth
Set map file width (>=10)
-X
Remove any local symbols from the symbol file
-Z
Remove trivial local symbols from the symbol file
--DISL=list
Specify disabled messages
--EDF=path
Specify message file location
--EMAX=number
Specify maximum number of errors
--NORLF
Do not relocate list file
--VER
Print version number and stop
If the standard input is a file then this file is assumed to contain the command-line
argument. Lines may be broken by leaving a backslash \ at the end of the preceding
line. In this fashion, HLINK commands of almost unlimited length may be issued. For
example, a link command file called x.lnk and containing the following text:
-Z -OX.OBJ -MX.MAP \
-Ptext=0,data=0/,bss,nvram=bss/. \
X.OBJ Y.OBJ Z.OBJ
may be passed to the linker by one of the following:
hlink @x.lnk
hlink < x.lnk
Several linker options require memory addresses or sizes to be specified. The syntax
for all these is similar. By default, the number will be interpreted as a decimal value. To
force interpretation as a HEX number, a trailing H, or h, should be added, for example,
765FH will be treated as a HEX number.
DS52053B-page 278
2012 Microchip Technology Inc.
Linker
7.2.1
-Aclass =low-high,...
Normally psects are linked according to the information given to a -P option (see
Section 7.2.19 “-Pspec”) but sometimes it is desirable to have a class of psects linked
into more than one non-contiguous address range. This option allows a number of
address ranges to be specified as a class. For example:
-ACODE=1020h-7FFEh,8000h-BFFEh
specifies that psects in the class CODE are to be linked into the given address ranges,
unless they are specifically linked otherwise.
Where there are a number of identical, contiguous address ranges, they may be
specified with a repeat count following an x character. For example:
-ACODE=0-0FFFFhx16
specifies that there are 16 contiguous ranges, each 64k bytes in size, starting from
address zero. Even though the ranges are contiguous, no psect will straddle a 64k
boundary, thus this may result in different psect placement to the case where the option
-ACODE=0-0FFFFFh
had been specified, which does not include boundaries on 64k multiples.
The -A option does not specify the memory space associated with the address. Once
a psect is allocated to a class, the space value of the psect is then assigned to the
class, see Section 6.4.9.3.13 “Space”.
7.2.2
-Cx
This option is now obsolete.
7.2.3
-Cpsect=class
This option will allow a psect to be associated with a specific class. Normally this is not
required on the command line since psect classes are specified in object files. See
Section 6.4.9.3.3 “Class”.
7.2.4
-Dclass=delta
This option allows the delta value for psects that are members of the specified class to
be defined. The delta value should be a number and represents the number of bytes
per addressable unit of objects within the psects. Most psects do not need this option
as they are defined with a delta value. See Section 6.4.9.3.4 “Delta”.
7.2.5
-Dsymfile
Use this option to produce an old-style symbol file. An old-style symbol file is an ASCII
file, where each line has the link address of the symbol followed by the symbol name.
7.2.6
-Eerrfile
Error messages from the linker are written to the standard error stream. Under DOS
there is no convenient way to redirect this to a file (the compiler drivers will redirect
standard error if standard output is redirected). This option will make the linker write all
error messages to the specified file instead of the screen, which is the default standard
error destination.
2012 Microchip Technology Inc.
DS52053B-page 279
MPLAB® XC8 C Compiler User’s Guide
7.2.7
-F
Normally the linker will produce an object file that contains both program code and data
bytes, and symbol information. Sometimes it is desired to produce a symbol-only object
file that can be used again in a subsequent linker run to supply symbol values. The -F
option will suppress data and code bytes from the output file, leaving only the symbol
records.
This option can be used when part of one project (i.e., a separate build) is to be shared
with other, as might be the case with a bootloader and application. The files for one
project are compiled using this linker option to produce a symbol-only object file; this is
then linked with the files for the other project.
7.2.8
-Gspec
When linking programs using segmented, or bank-switched psects, there are two ways
the linker can assign segment addresses, or selectors, to each segment. A segment is
defined as a contiguous group of psects where each psect in sequence has both its link
and load address concatenated with the previous psect in the group. The segment
address or selector for the segment is the value derived when a segment type
relocation is processed by the linker.
By default the segment selector will be generated by dividing the base load address of
the segment by the relocation quantum of the segment, which is based on the reloc=
flag value given to psects at the assembler level, see Section 6.4.9.3.11 “Reloc”. The
-G option allows an alternate method for calculating the segment selector. The
argument to -G is a string similar to:
A /10h-4h
where A represents the load address of the segment and / represents division. This
means “Take the load address of the psect, divide by 10 HEX, then subtract 4”. This
form can be modified by substituting N for A, * for / (to represent multiplication), and
adding rather than subtracting a constant. The token N is replaced by the ordinal
number of the segment, which is allocated by the linker. For example:
N*8+4
means “take the segment number, multiply by 8 then add 4”. The result is the segment
selector. This particular example would allocate segment selectors in the sequence 4,
12, 20, ... for the number of segments defined.
The selector of each psect is shown in the map file. See Section 7.4.2.2 “Psect
Information Listed by Module”.
7.2.9
-Hsymfile
This option will instruct the linker to generate a symbol file. The optional argument
symfile specifies the name of the file to receive the data. The default file name is
l.sym.
7.2.10
-H+symfile
This option will instruct the linker to generate an enhanced symbol file, which provides,
in addition to the standard symbol file, class names associated with each symbol and
a segments section which lists each class name and the range of memory it occupies.
This format is recommended if the code is to be run in conjunction with a debugger. The
optional argument symfile specifies a file to receive the symbol file. The default file
name is l.sym.
DS52053B-page 280
2012 Microchip Technology Inc.
Linker
7.2.11
-I
Usually failure to resolve a reference to an undefined symbol is a fatal error. Use of this
option will cause undefined symbols to be treated as warnings instead.
7.2.12
-Jerrcount
The linker will stop processing object files after a certain number of errors (other than
warnings). The default number is 10, but the -J option allows this to be altered.
7.2.13
-K
For older compilers that use a compiled stack, the linker will try and overlay function
auto and parameter blocks to reduce the total amount of RAM required. For debugging
purposes, this feature can be disabled with this option; however, doing so will increase
the data memory requirements.
This option has no effect when compiled stack allocation is performed by the code generator. This is the case for OCG (PRO-Standard-Free mode) compilers, and this option
should not be used.
7.2.14
-L
When the linker produces an output file it does not usually preserve any relocation
information, since the file is now absolute. In some circumstances a further “relocation”
of the program will be done at load time. The -L option will generate in the output file
one null relocation record for each relocation record in the input.
7.2.15
-LM
Similar to the above option, this preserves relocation records in the output file, but only
segment relocations.
7.2.16
-Mmapfile
This option causes the linker to generate a link map in the named file, or on the standard output if the file name is omitted. The format of the map file is illustrated in Section
Section 7.4 “Map Files”.
7.2.17
-N, -Ns and-Nc
By default the symbol table in the map file will be sorted by name. The -N option will
cause it to be sorted numerically, based on the value of the symbol. The -Ns and -Nc
options work similarly except that the symbols are grouped by either their space value,
or class.
7.2.18
-Ooutfile
This option allows specification of an output file name for the linker. The default output
file name is l.obj. Use of this option will override the default.
7.2.19
-Pspec
Psects are linked together and assigned addresses based on information supplied to
the linker via -P options. The argument to the -P option consists basically of comma
-separated sequences thus:
-Ppsect =lnkaddr+min/ldaddr+min,psect=lnkaddr/ldaddr,...
There are several variations, but essentially each psect is listed with its desired link and
load addresses, and a minimum value. All values may be omitted, in which case a
default will apply, depending on previous values.
2012 Microchip Technology Inc.
DS52053B-page 281
MPLAB® XC8 C Compiler User’s Guide
If present, the minimum value, min, is preceded by a + sign. It sets a minimum value
for the link or load address. The address will be calculated as described below, but if it
is less than the minimum then it will be set equal to the minimum.
The link and load addresses are either numbers, or the names of other psects, classes,
or special tokens.
If the link address is a negative number, the psect is linked in reverse order with the top
of the psect appearing at the specified address minus one. Psects following a negative
address will be placed before the first psect in memory.
If a psect’s link address is omitted, it will be derived from the top of the previous psect.
For example, in the following:
-Ptext=100h,data,bss
the text psect is linked at 100h (its load address defaults to the same). The data
psect will be linked (and loaded) at an address which is 100 HEX plus the length of the
text psect, rounded up as necessary if the data psect has a reloc value associated
with it (see Section 6.4.9.3.11 “Reloc”). Similarly, the bss psect will concatenate with
the data psect. Again:
-Ptext=-100h,data,bss
will link in ascending order bss, data then text with the top of the text psect
appearing at address 0ffh.
If the load address is omitted entirely, it defaults to the same as the link address. If the
slash / character is supplied, but no address is supplied after it, the load address will
concatenate with the previous psect. For example:
-Ptext=0,data=0/,bss
will cause both text and data to have a link address of zero; text will have a load
address of zero, and data will have a load address starting after the end of text. The
bss psect will concatenate with data in terms of both link and load addresses.
The load address may be replaced with a dot character, “.”. This tells the linker to set
the load address of this psect to the same as its link address. The link or load address
may also be the name of another (previously linked) psect. This will explicitly
concatenate the current psect with the previously specified psect, for example:
-Ptext=0,data=8000h/,bss/. -Pnvram=bss,heap
This example shows text at zero, data linked at 8000h but loaded after text; bss
is linked and loaded at 8000h plus the size of data, and nvram and heap are concatenated with bss. Note here the use of two -P options. Multiple -P options are
processed in order.
If -A options (see Section 7.2.1 “-Aclass =low-high,...”) have been used to specify
address ranges for a class then this class name may be used in place of a link or load
address, and space will be found in one of the address ranges. For example:
-ACODE=8000h-BFFEh,E000h-FFFEh
-Pdata=C000h/CODE
This will link data at C000h, but find space to load it in the address ranges associated
with the CODE class. If no sufficiently large space is available in this class, an error will
result. Note that in this case the data psect will still be assembled into one contiguous
block, whereas other psects in the class CODE will be distributed into the address
ranges wherever they will fit. This means that if there are two or more psects in class
CODE, they may be intermixed in the address ranges.
Any psects allocated by a -P option will have their load address range subtracted from
the address ranges associate with classes in the same memory space. This allows a
range to be specified with the -A option without knowing in advance how much of the
lower part of the range, for example, will be required for other psects.
DS52053B-page 282
2012 Microchip Technology Inc.
Linker
The final link and load address of psects are shown in the map file. See
Section 7.4.2.2 “Psect Information Listed by Module”.
7.2.20
-Qprocessor
This option allows a device type to be specified. This is purely for information placed in
the map file. The argument to this option is a string describing the device. There are no
behavioral changes attributable to the device type.
7.2.21
-S
This option prevents symbol information relating from being included in the symbol file
produced by the linker. Segment information is still included.
7.2.22
-Sclass =limit[,bound]
A class of psects may have an upper address limit associated with it. The following
example places a limit on the maximum address of the CODE class of psects to one less
than 400h.
-SCODE=400h
Note that to set an upper limit to a psect, this must be set in assembler code using the
psect limit flag, see Section 6.4.9.3.6 “Limit”).
If the bound (boundary) argument is used, the class of psects will start on a multiple of
the bound address. This example below places the FARCODE class of psects at a
multiple of 1000h, but with an upper address limit of 6000h.
-SFARCODE=6000h,1000h
7.2.23
-Usymbol
This option will enter the specified symbol into the linker’s symbol table as an undefined
symbol. This is useful for linking entirely from libraries, or for linking a module from a
library where the ordering has been arranged so that by default a later module will be
linked.
7.2.24
-Vavmap
To produce an Avocet format symbol file, the linker needs to be given a map file to allow
it to map psect names to Avocet memory identifiers. The avmap file will normally be
supplied with the compiler, or created automatically by the compiler driver as required.
7.2.25
-Wnum
The -W option can be used to set the warning level, in the range -9 to 9, or the width of
the map file, for values of num >= 10.
-W9 will suppress all warning messages. -W0 is the default. Setting the warning level
to -9 (-W-9) will give the most comprehensive warning messages.
7.2.26
-X
Local symbols can be suppressed from a symbol file with this option. Global symbols
will always appear in the symbol file.
7.2.27
-Z
Some local symbols are compiler generated and not of interest in debugging. This
option will suppress from the symbol file all local symbols that have the form of a single
alphabetic character, followed by a digit string. The set of letters that can start a trivial
symbol is currently “klfLSu“. The -Z option will strip any local symbols starting with
one of these letters, and followed by a digit string.
2012 Microchip Technology Inc.
DS52053B-page 283
MPLAB® XC8 C Compiler User’s Guide
7.2.28
--DISL=message numbers Disable Messages
This option is mainly used by the command-line driver, xc8, to disable particular
message numbers. It takes a comma-separate list of message numbers that will be
disabled during compilation.
This option is applied if compiling using xc8, the command-line driver and the
--MSGDISABLE driver option, see Section 4.8.38 “--MSGDISABLE: Disable
Warning Messages”.
See Section 4.6 “Compiler Messages” for full information about the compiler’s
messaging system.
7.2.29
--EDF=message file: Set Message File Path
This option is mainly used by the command-line driver, xc8, to specify the path of the
message description file. The default file is located in the dat directory in the compiler’s
installation directory.
See Section 4.6 “Compiler Messages” for full information about the compiler’s
messaging system.
7.2.30
--EMAX=number: Specify Maximum Number of Errors
This option is mainly used by the command-line driver, xc8, to specify the maximum
number of errors that can be encountered before the assembler terminates. The default
number is 10 errors.
This option is applied if compiling using xc8, the command-line driver and the
--ERRORS driver option, see Section 4.8.29 “--ERRORS: Maximum Number of
Errors”.
See Section 4.6 “Compiler Messages” for full information about the compiler’s
messaging system.
7.2.31
--NORLF: Do Not Relocate List File
Use of this option prevents the linker applying fixups to the assembly list file produced
by the assembler. This option is normally using by the command line driver, xc8, when
performing pre-link stages, but is omitted when performing the final link step so that the
list file shows the final absolute addresses.
If you are attempting to resolve fixup errors, this option should be disabled so as to fixup
the assembly list file and allow absolute addresses to be calculated for this file. If the
compiler driver detects the presence of a preprocessor macro __DEBUG which is
equated to 1, then this option will be disabled when building. This macro is set when
choosing a Debug build in MPLAB IDE, so always have this selected if you encounter
such errors.
7.2.32
--VER: Print Version Number
This option printed information relating to the version and build of the linker. The linker
will terminate after processing this option, even if other options and files are present on
the command line.
DS52053B-page 284
2012 Microchip Technology Inc.
Linker
7.3
RELOCATION AND PSECTS
This section looks at the input files that the linker has to work with.
The linker can read both relocatable object files and object-file libraries (.lib extension). The library files are a collection of object files packaged into a single unit, so
essentially we only need consider the format of object files.
Each object file consists of a number of records. Each record has a type that indicates
what sort of information it holds. Some record types hold general information about the
target device and its configuration, other records types may hold data, and others,
program debugging information, for example.
A lot of the information in object files relates to psects. Psects are an assembly domain
construct and are essentially a block of something, either instructions or data. Everything that contributes to the program is located in a psect. See
Section 6.4.8 “Program Sections” for an introductory guide. There is a particular
record type that is used to hold the data in psects. The bulk of each object file consists
of psect records containing the executable code and variables etc.
We are now in a position to look at the fundamental tasks the linker performs, which
are:
• combining all the relocatable object files into one
• relocation of psects contained in the object files into memory
• fixup of symbolic references in the psects
There is typically at least two object files that are passed to the linker. One will be produced from all the C code in the project, including C library code. There is only one of
these files since the code generator compiles and combines all the C code of the program and produces just the one assembly output. The other file passed to the linker will
be the object code produced from the runtime startup code, see
Section 4.4.2 “Startup and Initialization”.
If there are assembly source files in the project, then there will also be one object file
produced for each source file and these will be passed to the linker. Existing object files,
or object file libraries can also be specified in a project, and if present, these will also
be passed to the linker.
The output of the linker is also an object file, but there is only ever one file produced.
The file is absolute since relocation will have been performed by the linker. The output
file will consist of the information from all input object files merged together.
Relocation consists of placing the psect data into the memory of the target device.
The target device memory specification is passed to the linker by the way of linker
options. These options are generated by the command-line driver, xc8. There are no
linker scripts or means of specifying options in any source file. The default linker
options rarely need adjusting, but can be changed, if required and with caution, using
the driver option -L-, see Section 4.8.7 “-L-: Adjust Linker Options Directly”.
Once psects are placed at actual memory locations, symbolic references made in the
psects data can be replaced with absolute values. This is a process called fixup.
For each psect record in the object file, there is a corresponding relocation record that
indicates which bytes (or bits) in the psect record need to be adjusted once relocation
is complete. The relocation records also specify how the values are to be determined.
A linker fixup overflow error can occur if the value determined by the linker is too large
to fit in the “hole” reserved for the value in the psect. See Section “(477) fixup
overflow in expression (location 0x* (0x*+*), size *, value 0x*) (Linker)” for
information on finding the cause of these errors.
2012 Microchip Technology Inc.
DS52053B-page 285
MPLAB® XC8 C Compiler User’s Guide
7.4
MAP FILES
The map file contains information relating to the relocation of psects and the addresses
assigned to symbols within those psects.
7.4.1
Generation
If compilation is being performed via an IDE such as HI-TIDE or MPLAB IDE, a map
file is generated by default without you having to adjust the compiler options. If you are
using the driver from the command line then you’ll need to use the -M option to request
that the map file be produced, see Section 7.2.16 “-Mmapfile”. Map files use the
extension .map.
Map files are produced by the linker. If the compilation process is stopped before the
linker is executed, then no map file is produced. The linker will still produce a map file
even if it encounters errors, which will allow you to use this file to track down the cause
of the errors. However, if the linker ultimately reports too many errors then it did
not run to completion, and the map file will be either not created or not complete. You
can use the --ERRORS option (see Section 4.8.29 “--ERRORS: Maximum Number
of Errors”) on the command line to increase the number of errors before the linker
exits.
7.4.2
Contents
The sections in the map file, in order of appearance, are as follows.
•
•
•
•
•
•
•
•
•
The compiler name and version number
A copy of the command line used to invoke the linker
The version number of the object code in the first file linked
The machine type
A psect summary sorted by the psect’s parent object file
A psect summary sorted by the psect’s CLASS
A segment summary
Unused address ranges summary
The symbol table
Portions of an example map file, along with explanatory text, are shown in the following
sections.
7.4.2.1
GENERAL INFORMATION
At the top of the map file is general information relating to the execution of the linker.
When analyzing a program, always confirm the compiler version number shown in the
map file if you have more than one compiler version installed to ensure the desired
compiler is being executed.
The device selected with the --CHIP option (Section 4.8.20 “--CHIP: Define
Device”) or that select in your IDE, should appear after the Machine type entry.
The object code version relates to the file format used by relocatable object files produced by the assembler. Unless either the assembler or linker have been updated independently, this should not be of concern.
DS52053B-page 286
2012 Microchip Technology Inc.
Linker
A typical map file may begin something like the following. This example has been cut
down for clarity.
--edf=/home/jeff/Microchip/XC8/1.00/dat/en_msgs.txt -cs -h+main.sym -z \
-Q16F946 -ol.obj -Mmain.map -ver=XC8 -ACONST=00h-0FFhx32 \
-ACODE=00h-07FFhx4 -ASTRCODE=00h-01FFFh -AENTRY=00h-0FFhx32 \
-ASTRING=00h-0FFhx32 -ACOMMON=070h-07Fh -ABANK0=020h-06Fh \
-ABANK1=0A0h-0EFh -ABANK2=0120h-016Fh -ABANK3=01A0h-01EFh \
-ARAM=020h-06Fh,0A0h-0EFh,0120h-016Fh,01A0h-01EFh \
-AABS1=020h-07Fh,0A0h-0EFh,0120h-016Fh,01A0h-01EFh -ASFR0=00h-01Fh \
-ASFR1=080h-09Fh -ASFR2=0100h-011Fh -ASFR3=0180h-019Fh \
-preset_vec=00h,intentry,init,end_init -ppowerup=CODE -pfunctab=CODE \
-ACONFIG=02007h-02007h -pconfig=CONFIG -DCONFIG=2 -AIDLOC=02000h-02003h \
-pidloc=IDLOC -DIDLOC=2 -AEEDATA=00h-0FFh/02100h -peeprom_data=EEDATA \
-DEEDATA=2 -DCODE=2 -DSTRCODE=2 -DSTRING=2 -DCONST=2 -DENTRY=2 -k \
startup.obj main.obj
Object code version is 3.10
Machine type is 16F946
The Linker command line shows all the command-line options and files that were
passed to the linker for the last build. Remember, these are linker options and not
command-line driver options.
The linker options are necessarily complex. Fortunately, they rarely need adjusting
from their default settings. They are formed by the command-line driver, xc8, based on
the selected target device and the specified driver options. You can often confirm that
driver options were valid by looking at the linker options in the map file. For example, if
you ask the driver to reserve an area of memory, you should see a change in the linker
options used.
If the default linker options must be changed, this can be done indirectly through the
driver using the driver -L- option, see Section 4.8.7 “-L-: Adjust Linker Options
Directly”. If you use this option, always confirm the change appears correctly in the
map file.
7.4.2.2
PSECT INFORMATION LISTED BY MODULE
The next section in the map file lists those modules that made a contribution to the output, and information regarding the psects these modules defined. See
Section 5.15.1 “Program Sections” for an introductory explanation of psects.
This section is heralded by the line that contains the headings:
Name
Link
Load
Length
Selector
Space
Scale
Under this on the far left is a list of object files. These object files include both files generated from source modules and those that were extracted from object library files
(.lib extension). In the latter case, the name of the library file is printed before the
object file list. Note that since the code generator combines all C source files (and
p-code libraries), there will only be one object file representing the entire C part of the
program. The object file corresponding to the runtime startup code is normally present
in this list.
The information in this section of the map file can be used to confirm that a module is
making a contribution to the output file and to determine the exact psects that each
module defines.
Shown are all the psects (under the Name column) that were linked into the program
from each object file, and information about that psect.
The linker deals with two kinds of addresses: link and load. Generally speaking the link
address of a psect is the address by which it will be accessed at run time.
2012 Microchip Technology Inc.
DS52053B-page 287
MPLAB® XC8 C Compiler User’s Guide
The load address, which is often the same as the link address, is the address at which
the psect will start within the output file (HEX or binary file etc.). If a psect is used to
hold bits, the load address is irrelevant and is instead used to hold the link address (in
bit units) converted into a byte address.
The Length of the psect is shown in the units used by that psect.
The Selector is less commonly used and is of no concern when compiling for PIC
devices.
The Space field is important as it indicates the memory space in which the psect was
placed. For Harvard architecture machines, with separate memory spaces (such as the
PIC10/12/16 devices), this field must be used in conjunction with the address to specify
an exact storage location. A space of 0 indicates the program memory, and a space of
1 indicates the data memory. See Section 6.4.9.3.13 “Space”.
The Scale of a psect indicates the number of address units per byte. This is left blank
if the scale is 1 and will show 8 for psects that hold bit objects. The load address of
psects that hold bits is used to display the link address converted into units of bytes,
rather than the load address. See Section 6.4.9.3.2 “Bit”.
For example, the following appears in a map file.
ext.obj
Name
text
bss
rbit
Link
3A
4B
50
Load
3A
4B
A
Length Selector
22
30
10
4B
2
0
Space
0
1
1
Scale
8
This indicates that one of the files that the linker processed was called ext.obj. (This
may have been derived from C code or a source file called ext.as.)
This object file contained a text psect, as well as psects called bss and rbit.
The psect text was linked at address 3A and bss at address 4B. At first glance, this
seems to be a problem given that text is 22 words long; however, they are in different
memory areas, as indicated by the space flag (0 for text and 1 for bss), and so do not
occupy the same memory.
The psect rbit contains bit objects, and this can be confirmed by looking it the scale
value, which is 8. Again, at first glance there seems there could be an issue with rbit
linked over the top of bss. Their space flags are the same, but since rbit contains bit
objects, its link address is in units of bits. The load address field of rbit psect displays
the link address converted to byte units, i.e., 50h/8 => Ah.
Underneath the object file list there may be a label COMMON. This shows the contribution to the program from program-wide psects, in particular that used by the compiled
stack.
7.4.2.3
PSECT INFORMATION LISTED BY CLASS
The next section in the map file shows the same psect information but grouped by the
psects’ class.
This section is heralded by the line that contains the headings:
TOTAL
Name
Link
Load
Length
Under this are the class names followed by those psects which belong to this class, see
Section 6.4.9.3.3 “Class”. These psects are the same as those listed by module in the
above section; there is no new information contained in this section, just a different
presentation.
DS52053B-page 288
2012 Microchip Technology Inc.
Linker
7.4.2.4
SEGMENT LISTING
The class listing in the map file is followed by a listing of segments. A segment is conceptual grouping of contiguous psects in the same memory space, and are used by the
linker as an aid in psect placement. There is no segment assembler directive and
segments cannot be controlled in any way.
This section is heralded by the line that contains the headings:
SEGMENTS
Name
Load
Length
Top
Selector
Space
Class
The name of a segment is derived from the psect in the contiguous group with the lowest link address. This can lead to confusion with the psect with the same name. Do not
read psect information from this section of the map file.
Typically this section of the map file can be ignored by the user.
7.4.2.5
UNUSED ADDRESS RANGES
The last of the memory summaries show the memory is has not been allocated, and is
hence unused. The linker is aware of any memory allocated by the code generator (for
absolute variables), and so this free space is accurate.
This section follows the heading:
UNUSED ADDRESS RANGES
and is followed by a list of classes and the memory still available in each class. If there
is more than one memory range available in a class, each range is printed on a
separate line. Any paging boundaries within a class are not displayed, but the column
Largest block shows the largest contiguous free space which takes into account any
paging in the memory range. If you are looking to see why psects cannot be placed into
memory (e.g., cant-find-space type errors) then this important information to study.
Note that the memory associated with a class can overlap that in others, thus the total
free space is not simply the addition of all the unused ranges.
7.4.2.6
SYMBOL TABLE
The final section in the map file list global symbols that the program defines. This
section has a heading:
Symbol Table
and is followed by two columns in which the symbols are alphabetically listed. As
always with the linker, any C derived symbol is shown with its assembler equivalent
symbol name. See Section 5.12.3 “Interaction Between Assembly and C Code”.
The symbols listed in this table are:
• Global assembly labels
• Global EQU /SET assembler directive labels
• Linker-defined symbols
Assembly symbols are made global via the GLOBAL assembler directive, see
Section 6.4.9.1 “GLOBAL” for more information.
Linker-defined symbols act like EQU directives; however, they are defined by the linker
during the link process, and no definition for them will appear in any source or
intermediate file. See Section 5.15.6 “Linker-Defined Symbols”.
Each symbol is shown with the psect in which they are placed, and the value (usually
an address) which the symbol has been assigned. There is no information encoded into
a symbol to indicate whether it represents code or data, nor in which memory space it
resides.
2012 Microchip Technology Inc.
DS52053B-page 289
MPLAB® XC8 C Compiler User’s Guide
If the psect of a symbol is shown as (abs), this implies that the symbol is not directly
associated with a psect. Such is the case for absolute C variables, or any symbols that
are defined using an EQU directive in assembly.
Note that a symbol table is also shown in each assembler list file. (See
Section 4.8.16 “--ADDRQUAL: Set Compiler Response to Memory Qualifiers” for
information on generating these files.) These differ to that shown in the map file in that
they list also list local symbols, and only show symbols defined in the corresponding
module.
DS52053B-page 290
2012 Microchip Technology Inc.
MPLAB® XC8 C COMPILER
USER’S GUIDE
Chapter 8. Utilities
8.1
INTRODUCTION
This chapters discusses some of the utility applications that are bundled with the
compiler.
Some of these applications may not be normally invoked when building, but can be
manually executed to perform certain tasks.
The following applications are described in this chapter of the MPLAB XC8 C Compiler
User’s Guide:
•
•
•
•
•
8.2
Librarian
OBJTOHEX
CREF
CROMWELL
HEXMATE
LIBRARIAN
The librarian program, LIBR, has the function of combining several files into a single
file known as a library. The reasons you might want to use a library in a project are:
• there will be fewer files to link
• the file content will be accessed faster
• libraries uses less disk space
The librarian can build p-code libraries (.lpp extension) from p-code files (.p1 extension), or object code libraries (.lib extension) from object files (.obj extension).
P-code libraries should be only created if all the library source code is written in C.
Object code libraries should be used for assembly code that is to be built into a library.
With both library types, only those modules required by a program will be extracted and
included in the program output.
8.2.1
The Library Format
The modules in a library are simply concatenated, but a directory of the modules and
symbols in the library is maintained at the beginning of a library file. Since this directory
is smaller than the sum of the modules, on the first pass the linker can perform faster
searches just reading the directory, and not all the modules. On the second pass it need
read only those modules which are required, seeking over the others. This all
minimizes disk I/O when linking.
It should be noted that the library format is not a general purpose archiving mechanism
as is used by some other compiler systems. This has the advantage that the format
may be optimized toward speeding up the linkage process.
2012 Microchip Technology Inc.
DS52053B-page 291
MPLAB® XC8 C Compiler User’s Guide
8.2.2
Using the Librarian
Library files can be built directly using the command-line driver, see
Section 4.8.44 “--OUTPUT= type: Specify Output File Type”. In this case the driver
will invoke LIBR with the appropriate options saving you from having to use the librarian directly. You may wish to perform this step manually, or you may need to look at the
contents of library files, for example. This section shows how the librarian can be executed from the command-line. The librarian cannot be called from IDEs, such as
MPLAB IDE.
The librarian program is called LIBR, and the formats of commands to it are as follows:
LIBR [options]
LIBR [options]
k
k
file.lpp [file1.p1 file2.p1...]
file.lib [file1.obj file2.obj ...]
The options are zero or more librarian options which affect the output of the program.
These are listed in Table 8-1.
TABLE 8-1:
LIBRARIAN COMMAND-LINE OPTIONS
Option
-P width
-W
Effect
Specify page width
Suppress non-fatal errors
A key letter, k, denotes the command requested of the librarian (replacing, extracting
or deleting modules, listing modules or symbols). These commands are listed in
Table 8-2.
TABLE 8-2:
LIBRARIAN KEY LETTER COMMANDS
Key
Meaning
r
Replace modules
d
Delete modules
x
Extract modules
m
List modules
s
List modules with symbols
o
Re-order modules
The first file name listed after the key is the name of the library file to be used. The
following files, if required, are the modules of the library required by the command
specified.
If you are building a p-code library, the modules listed must be p-code files. If you are
building an object file library, the modules listed must be object files.
When replacing or extracting modules, the names of the modules to be replaced or
extracted must be specified. If no names are supplied, all the modules in the library will
be replaced or extracted respectively.
Adding a file to a library is performed by requesting the librarian to replace it in the
library. Since it is not present, the module will be appended to the library. If the r key is
used and the library does not exist, it will be created.
When using the d key letter, the named modules will be deleted from the library. In this
instance, it is an error not to give any module names.
The m and s key letters will list the named modules and, in the case of the s key letter,
the global symbols defined or referenced within. A D or U letter is used to indicate
whether each symbol is defined in the module, or referenced but undefined. As with the
r and x key letters, an empty list of modules means all the modules in the library.
DS52053B-page 292
2012 Microchip Technology Inc.
Utilities
The o key takes a list of module names and re-orders the matching modules in the
library file so that they have the same order as the one listed on the command line.
Modules that are not listed are left in their existing order, and will appear after the
re-ordered modules.
8.2.2.1
EXAMPLES
Here are some examples of usage of the librarian. The following command:
LIBR s pic-stdlib-d24.lpp ctime.p1
lists the global symbols in the modules ctime.p1, as shown here:
ctime.p1
D
D
D
D
D
_moninit
_localtime
_gmtime
_asctime
_ctime
The D letter before each symbol indicates that these symbols are defined by the
module.
Using the command above without specifying the module name will list all the symbols
defined (or undefined) in the library.
The following command deletes the object modules a.obj, b.obj and c.obj from
the library lcd.lib:
LIBR d lcd.lib a.obj b.obj c.obj
8.2.3
Supplying Arguments
Since it is often necessary to supply many object file arguments to LIBR, arguments
will be read from standard input if no command-line arguments are given. If the
standard input is attached to the console, LIBR will prompt for input.
Multiple line input may be given by using a backslash as a continuation character on
the end of a line. If standard input is redirected from a file, LIBR will take input from the
file, without prompting. For example:
libr
libr> r file.lib 1.obj 2.obj 3.obj \
libr> 4.obj 5.obj 6.obj
will perform much the same as if the object files had been typed on the command line.
The libr> prompts were printed by LIBR itself, the remainder of the text was typed
as input.
libr prompt. A backslash at the end of the line will be interpreted to mean that
more command lines follow.
CREF takes the options listed in Section Table 8-4: “CREF Command-line Options”.
TABLE 8-4:
CREF COMMAND-LINE OPTIONS
Option
Meaning
-Fprefix
Exclude symbols from files with a pathname
or filename starting with prefix
-Hheading
Specify a heading for the listing file
-Llen
Specify the page length for the listing file
-Ooutfile
Specify the name of the listing file
-Pwidth
Set the listing width
-Sstoplist
Read file stoplist and ignore any symbols
listed.
-Xprefix
Exclude any symbols starting with prefix
--EDF
Specify message file location
--EMAX
Specify maximum number of errors
--MSGDISABLE
Specify disabled messages
--VER
Print version number and stop
Each option is described in more detail in the following sections.
8.4.1
-Fprefix
It is often desired to exclude from the cross-reference listing any symbols defined in a
system header file, e.g., . The -F option allows specification of a path
name prefix that will be used to exclude any symbols defined in a file whose path name
begins with that prefix. For example, -F\ will exclude any symbols from all files with a
path name starting with \.
8.4.2
-Hheading
The -H option takes a string as an argument which will be used as a header in the listing. The default heading is the name of the first raw cross-ref information file specified.
8.4.3
-Llen
Specify the length of the paper on which the listing is to be produced, e.g., if the listing
is to be printed on 55 line paper you would use a -L55 option. The default is 66 lines.
2012 Microchip Technology Inc.
DS52053B-page 297
MPLAB® XC8 C Compiler User’s Guide
8.4.4
-Ooutfile
Allows specification of the output file name. By default the listing will be written to the
standard output and may be redirected in the usual manner. Alternatively outfile
may be specified as the output file name.
8.4.5
-Pwidth
This option allows the specification of the width to which the listing is to be formatted,
e.g., -P132 will format the listing for a 132 column printer. The default is 80 columns.
8.4.6
-Sstoplist
The -S option should have as its argument the name of a file containing a list of symbols not to be listed in the cross-reference. Symbols should be listed, one per line in
the file. Use the C domain symbols. Multiple stoplists may be supplied with multiple -S
options.
8.4.7
-Xprefix
The -X option allows the exclusion of symbols from the listing, based on a prefix given
as argument to -X. For example, if it was desired to exclude all symbols starting with
the character sequence xyz then the option -Xxyz would be used. If a digit appears
in the character sequence then this will match any digit in the symbol, e.g., -XX0 would
exclude any symbols starting with the letter X followed by a digit.
8.4.8
--EDF=message file: Set Message File Path
This option is mainly used by the command-line driver, xc8, to specify the path of the
message description file. The default file is located in the dat directory in the compiler’s
installation directory.
See Section 4.6 “Compiler Messages” for full information about the compiler’s
messaging system.
8.4.9
--EMAX=number: Specify Maximum Number of Errors
This option is mainly used by the command-line driver, xc8, to specify the maximum
number of errors that can be encountered before CREF terminates. The default number
is 10 errors.
This option is applied if compiling using xc8, the command-line driver and the
--ERRORS driver option, see Section 4.8.29 “--ERRORS: Maximum Number of
Errors”.
See Section 4.6 “Compiler Messages” for full information about the compiler’s
messaging system.
8.4.10
--MSGDISABLE=message numbers Disable Messages
This option is mainly used by the command-line driver, xc8, to disable particular
message numbers. It takes a comma-separate list of message numbers that will be
disabled during compilation.
This option is applied if compiling using xc8, the command-line driver and the
--MSGDISABLE driver option, see Section 4.8.38 “--MSGDISABLE: Disable
Warning Messages”.
See Section 4.6 “Compiler Messages” for full information about the compiler’s
messaging system.
DS52053B-page 298
2012 Microchip Technology Inc.
Utilities
8.4.11
--VER: Print Version Number
This option prints information relating to the version and build of CREF. CREF will terminate after processing this option, even if other options and files are present on the
command line.
2012 Microchip Technology Inc.
DS52053B-page 299
MPLAB® XC8 C Compiler User’s Guide
8.5
CROMWELL
The CROMWELL utility converts code and symbol files into different formats. These files
are typically used by debuggers and allow source-level debugging of code. The output
formats available are shown in Table 8-5.
TABLE 8-5:
CROMWELL FORMAT TYPES
Key
Format
cod
Bytecraft COD file
coff
COFF file format
elf
ELF/DWARF file
eomf51
Extended OMF-51 format
hitech
HI-TECH Software format
icoff
ICOFF file format
ihex
Intel HEX file format
mcoff
Microchip COFF file format
omf51
OMF-51 file format
pe
P&E file format
s19
Motorola HEX file format
The CROMWELL application is automatically executed by the command-line driver when
required. The following information is required if running the application manually.
The general form of the CROMWELL command is:
CROMWELL [options] inputFiles -okey [outputFile]
where options can be any of the options shown in Table 8-6.
TABLE 8-6:
CROMWELL COMMAND-LINE OPTIONS
Option
Description
-Pname[,architecture]
Device name and architecture
-N
Identify code classes
-D
Dump input file
-C
Identify input files only
-F
Fake local symbols as global
-Okey
Set the output format
-Ikey
Set the input format
-L
List the available formats
-E
Strip file extensions
-B
Specify big-endian byte ordering
-M
Strip underscore character
-V
Verbose mode
--EDF=path
Specify message file location
--EMAX=number
Specify maximum number of errors
--MSGDISABLE=list
Specify disabled messages
--VER
Print version number and stop
The outputFile (optional) is the name of the output file. The inputFiles are
typically the HEX and SYM file.
CROMWELL automatically searches for the SDB files and reads those if they are found.
The options are further described in the following paragraphs.
DS52053B-page 300
2012 Microchip Technology Inc.
Utilities
8.5.1
-Pname[,architecture]
The -P options takes a string which is the name of the device used. CROMWELL may
use this in the generation of the output format selected.
Note that to produce output in COFF format an additional argument to this option which
also specifies the device architecture is required. Hence for this format the usage of this
option must take the form: -Pname,architecture. Table 8-7 enumerates the
architectures supported for producing COFF files.
TABLE 8-7:
ARCHITECTURE ARGUMENTS
Architecture
Description
PIC12
Microchip baseline PIC® MCU chips
PIC14
Microchip mid-range PIC MCU chips
PIC14E
Microchip Enhanced mid-range PIC MCU
chips
PIC16
Microchip high-end (17CXXX) PIC MCU chips
PIC18
Microchip PIC18 chips
PIC24
Microchip PIC24F and PIC24H chips
PIC30
Microchip dsPIC30 and dsPIC33 chips
8.5.2
-N
To produce some output file formats (e.g., COFF), CROMWELL requires that the names
of the program memory space psect classes be provided. The names of the classes
are specified as a comma-separated list. See the map file (Section 7.4 “Map Files”)
to determine which classes the linker uses.
For example, mid-range devices typically requires -NCODE,CONST,ENTRY,STRING.
8.5.3
-D
The -D option is used to display details about the named input file in a human-readable
format. This option is useful if you need to check the contents of the file, which are
usually binary files. The input file can be one of the file types as shown in Table 8-5.
8.5.4
-C
This option will attempt to identify if the specified input files are one of the formats as
shown in Table 8-5. If the file is recognized, a confirmation of its type will be displayed.
8.5.5
-F
When generating a COD file, this option can be used to force all local symbols to be
represented as global symbols. The may be useful where an emulator cannot read
local symbol information from the COD file.
8.5.6
-Okey
This option specifies the format of the output file. The key can be any of the types listed
in Table 8-5.
8.5.7
-Ikey
This option can be used to specify the default input file format. The key can be any of
the types listed in Table 8-5.
2012 Microchip Technology Inc.
DS52053B-page 301
MPLAB® XC8 C Compiler User’s Guide
8.5.8
-L
Use this option to show what file format types are supported. A list similar to that given
in Table 8-5 will be shown.
8.5.9
-E
Use this option to tell CROMWELL to ignore any filename extensions that were given.
The default extension will be used instead.
8.5.10
-B
In formats that support different endian types, use this option to specify big-endian byte
ordering.
8.5.11
-M
When generating COD files this option will remove the preceding underscore character
from symbols.
8.5.12
-V
Turns on verbose mode that displays information about which operations CROMWELL is
performing.
8.5.13
--EDF=message file: Set Message File Path
This option is mainly used by the command-line driver, xc8, to specify the path of the
message description file. The default file is located in the dat directory in the compiler’s
installation directory. Also, see Section 4.6 “Compiler Messages” for full information
about the compiler’s messaging system.
8.5.14
--EMAX=number: Specify Maximum Number of Errors
This option is mainly used by the command-line driver, xc8, to specify the maximum
number of errors that can be encountered before CROMWELL terminates. The default
number is 10 errors.
This option is applied if compiling using xc8, the command-line driver and the
--ERRORS driver option, see Section 4.8.29 “--ERRORS: Maximum Number of
Errors”. Also, see Section 4.6 “Compiler Messages” for full information about the
compiler’s messaging system.
8.5.15
--MSGDISABLE=message numbers Disable Messages
This option is mainly used by the command-line driver, xc8, to disable particular
message numbers. It takes a comma-separate list of message numbers that will be
disabled during compilation.
This option is applied if compiling using xc8, the command-line driver and the
--MSGDISABLE driver option, see Section 4.8.38 “--MSGDISABLE: Disable Warning Messages”. Also, see Section 4.6 “Compiler Messages” for full information
about the compiler’s messaging system.
8.5.16
--VER: Print Version Number
This option prints information relating to the version and build of CROMWELL. CROMWELL
will terminate after processing this option, even if other options and files are present on
the command line.
DS52053B-page 302
2012 Microchip Technology Inc.
Utilities
8.6
HEXMATE
The HEXMATE utility is a program designed to manipulate Intel HEX files. HEXMATE is
a post-link stage utility which is automatically invoked by the compiler driver, and that
provides the facility to:
•
•
•
•
•
•
•
•
•
Calculate and store variable-length checksum values
Fill unused memory locations with known data sequences
Merge multiple Intel HEX files into one output file
Convert INHX32 files to other INHX formats (e.g., INHX8M)
Detect specific or partial opcode sequences within a HEX file
Find/replace specific or partial opcode sequences
Provide a map of addresses used in a HEX file
Change or fix the length of data records in a HEX file.
Validate checksums within Intel HEX files.
Typical applications for HEXMATE might include:
• Merging a bootloader or debug module into a main application at build time
• Calculating a checksum over a range of program memory and storing its value in
program memory or EEPROM
• Filling unused memory locations with an instruction to send the PC to a known
location if it gets lost.
• Storage of a serial number at a fixed address.
• Storage of a string (e.g., time stamp) at a fixed address.
• Store initial values at a particular memory address (e.g., initialize EEPROM)
• Detecting usage of a buggy/restricted instruction
• Adjusting HEX file to meet requirements of particular bootloaders
2012 Microchip Technology Inc.
DS52053B-page 303
MPLAB® XC8 C Compiler User’s Guide
8.6.1
HEXMATE Command Line Options
HEXMATE is automatically called by the command line driver, xc8. This is primarily to
merge in HEX files with the output generated by the source files; however, there are
some xc8 options which directly map to HEXMATE options, and so other functionality
can be requested without having to run HEXMATE explicitly on the command line. For
other functionality, the following details the options available when running this
application.
If HEXMATE is to be run directly, its usage is:
HEXMATE [specs,]file1.HEX [[specs,]file2.HEX ... [specs,]fileN.HEX]
[options]
Where file1.HEX through to fileN.HEX form a list of input Intel HEX files to merge
using HEXMATE. If only one HEX file is specified, then no merging takes place, but other
functionality is specified by additional options. Table 8-8 lists the command line options
that HEXMATE accepts.
TABLE 8-8:
HEXMATE COMMAND-LINE OPTIONS
Option
Effect
-ADDRESSING
Set address fields in all HEXMATE options to use word
addressing or other
-BREAK
Break continuous data so that a new record begins at a set
address
-CK
Calculate and store a checksum value
-FILL
Program unused locations with a known value
-FIND
Search and notify if a particular code sequence is detected
-FIND...,DELETE
Remove the code sequence if it is detected (use with caution)
-FIND...,REPLACE
Replace the code sequence with a new code sequence
-FORMAT
Specify maximum data record length or select INHX variant
-HELP
Show all options or display help message for specific option
-LOGFILE
Save HEXMATE analysis of output and various results to a file
-Ofile
Specify the name of the output file
-SERIAL
Store a serial number or code sequence at a fixed address
-SIZE
Report the number of bytes of data contained in the resultant
HEX image.
-STRING
Store an ASCII string at a fixed address
-STRPACK
Store an ASCII string at a fixed address using string packing
-W
Adjust warning sensitivity
+
Prefix to any option to overwrite other data in its address range
if necessary
The input parameters to HEXMATE are now discussed in greater detail. Note that any
integral values supplied to the HEXMATE options should be entered as hexadecimal
values without leading 0x or trailing h characters. Note also that any address fields
specified in these options are to be entered as byte addresses, unless specified
otherwise in the -ADDRESSING option.
DS52053B-page 304
2012 Microchip Technology Inc.
Utilities
8.6.1.1
SPECIFICATIONS,FILENAME.HEX
Intel HEX files that can be processed by HEXMATE should be in either INHX32 or
INHX8M format. Additional specifications can be applied to each HEX file to put
restrictions or conditions on how this file should be processed.
If any specifications are used they must precede the filename. The list of specifications
will then be separated from the filename by a comma.
A range restriction can be applied with the specification rStart-End. A range restriction will cause only the address data falling within this range to be used. For example:
r100-1FF,myfile.hex
will use myfile.hex as input, but only process data which is addressed within the
range 100h-1FFh (inclusive) from that file.
An address shift can be applied with the specification sOffset. If an address shift is
used, data read from this HEX file will be shifted (by the offset specified) to a new
address when generating the output. The offset can be either positive or negative. For
example:
r100-1FFs2000,myfile.HEX
will shift the block of data from 100h-1FFh to the new address range 2100h-21FFh.
Be careful when shifting sections of executable code. Program code should only be
shifted if it is position independent.
8.6.1.2
+ PREFIX
When the + operator precedes an argument or input file, the data obtained from that
source will be forced into the output file and will overwrite another other data existing
at that address range. For example:
+input.HEX +-STRING@1000=”My string”
Ordinarily, HEXMATE will issue an error if two sources try to store differing data at the
same location. Using the + operator informs HEXMATE that if more than one data
source tries to store data to the same address, the one specified with a + prefix will take
priority.
8.6.1.3
-ADDRESSING
By default, all address arguments in HEXMATE options expect that values will be
entered as byte addresses. In some device architectures the native addressing format
may be something other than byte addressing. In these cases it would be much simpler
to be able to enter address-components in the device’s native format. To facilitate this,
the -ADDRESSING option is used.
This option takes exactly one parameter which configures the number of bytes contained per address location. If, for example, a device’s program memory naturally used
a 16-bit (2 byte) word-addressing format, the option -ADDRESSING=2 will configure
HEXMATE to interpret all command line address fields as word addresses. The affect of
this setting is global and all HEXMATE options will now interpret addresses according to
this setting. This option will allow specification of addressing modes from one byte per
address to four bytes per address.
8.6.1.4
-BREAK
This option takes a comma-separated list of addresses. If any of these addresses are
encountered in the HEX file, the current data record will conclude and a new data
record will recommence from the nominated address. This can be useful to use new
data records to force a distinction between functionally different areas of program
space. Some HEX file readers depend on this.
2012 Microchip Technology Inc.
DS52053B-page 305
MPLAB® XC8 C Compiler User’s Guide
8.6.1.5
-CK
The -CK option is for calculating a checksum. The usage of this option is:
-CK=start-end@destination [+offset][wWidth][tCode][gAlogithm]
where:
• start and end specify the address range over which the checksum will be
calculated.
• destination is the address where the checksum result will be stored. This
value cannot be within the range of calculation.
• offset is an optional initial value to add to the checksum result.
• Width is optional and specifies the byte-width of the checksum result. Results
can be calculated for byte-widths of 1 to 4 bytes. If a positive width is requested,
the result will be stored in big-endian byte order. A negative width will cause the
result to be stored in little-endian byte order. If the width is left unspecified, the
result will be 2 bytes wide and stored in little-endian byte order.
• Code is a hexadecimal code that will trail each byte in the checksum result. This
can allow each byte of the checksum result to be embedded within an instruction.
• Algorithm is an integer to select which HEXMATE algorithm to use to calculate
the checksum result. A list of selectable algorithms are given in Table 8-9. If
unspecified, the default checksum algorithm used is 8 bit addition (1).
A typical example of the use of the checksum option is:
-CK=0-1FFF@2FFE+2100w2
This will calculate a checksum over the range 0-1FFFh and program the checksum
result at address 2FFEh. The checksum value will be offset by 2100h. The result will
be two bytes wide.
TABLE 8-9:
HEXMATE CHECKSUM ALGORITHM SELECTION
Selector
DS52053B-page 306
Algorithm description
-4
Subtraction of 32 bit values from initial value
-3
Subtraction of 24 bit values from initial value
-2
Subtraction of 16 bit values from initial value
-1
Subtraction of 8 bit values from initial value
1
Addition of 8 bit values from initial value
2
Addition of 16 bit values from initial value
3
Addition of 24 bit values from initial value
4
Addition of 32 bit values from initial value
7
Fletcher’s checksum (8 bit)
8
Fletcher’s checksum (16 bit)
2012 Microchip Technology Inc.
Utilities
8.6.1.6
-FILL
The -FILL option is used for filling unused memory locations with a known value. The
usage of this option is:
-FILL=[const_width:]fill_expr[@address[:end_address]]
where:
• const_width has the form wn and signifies the width (n bytes) of each constant
in fill_expr. If const_width is not specified, the default value is the native
width of the architecture. That is, -FILL=w1:1 with fill every byte with the value
0x01.
• fill_expr can use the syntax (where const and increment are n-byte
constants):
- const fill memory with a repeating constant; i.e., -FILL=0xBEEF becomes
0xBEEF, 0xBEEF, 0xBEEF, 0xBEEF
- const+=increment fill memory with an incrementing constant; i.e.,
-FILL=0xBEEF+=1 becomes 0xBEEF, 0xBEF0, 0xBEF1, 0xBEF2
- const-=increment fill memory with a decrementing constant; i.e.,
-FILL=0xBEEF-=0x10 becomes 0xBEEF, 0xBEDF, 0xBECF, 0xBEBF
- const,const,...,const fill memory with a list of repeating constants; i.e.,
-FILL=0xDEAD,0xBEEF becomes 0xDEAD,0xBEEF,0xDEAD,0xBEEF
• The options following fill_expr result in the following behavior:
- @address fill a specific address with fill_expr; i.e.,
-FILL=0xBEEF@0x1000 puts 0xBEEF at address 1000h
- @address:end_address fill a range of memory with fill_expr; i.e.,
-FILL=0xBEEF@0:0xFF puts 0xBEEF in unused addresses between 0 and
255
All constants can be expressed in (unsigned) binary, octal, decimal or hexadecimal, as
per normal C syntax, for example, 1234 is a decimal value, 0xFF00 is hexadecimal and
FF00 is illegal.
8.6.1.7
-FIND
This option is used to detect and log occurrences of an opcode or partial code
sequence. The usage of this option is:
-FIND=Findcode [mMask]@Start-End [/Align][w][t”Title”]
where:
• Findcode is the hexadecimal code sequence to search for and is entered in little
endian byte order.
• Mask is optional. It specifies a bit mask applied over the Findcode value to allow
a less restrictive search. It is entered in little endian byte order.
• Start and End limit the address range to search.
• Align is optional. It specifies that a code sequence can only match if it begins on
an address which is a multiple of this value.
• w, if present, will cause HEXMATE to issue a warning whenever the code sequence
is detected.
• Title is optional. It allows a title to be given to this code sequence. Defining a
title will make log-reports and messages more descriptive and more readable. A
title will not affect the actual search results.
2012 Microchip Technology Inc.
DS52053B-page 307
MPLAB® XC8 C Compiler User’s Guide
Here are some examples.
The option -FIND=3412@0-7FFF/2w will detect the code sequence 1234h when
aligned on a 2 (two) byte address boundary, between 0h and 7FFFh. w indicates that
a warning will be issued each time this sequence is found.
In this next example, -FIND=3412M0F00@0-7FFF/2wt”ADDXY”, the option is the
same as in last example but the code sequence being matched is masked with 000Fh,
so HEXMATE will search for any of the opcodes 123xh, where x is any digit. If a
byte-mask is used, is must be of equal byte-width to the opcode it is applied to. Any
messaging or reports generated by HEXMATE will refer to this opcode by the name,
ADDXY as this was the title defined for this search.
If HEXMATE is generating a log file, it will contain the results of all searches. -FIND
accepts whole bytes of HEX data from 1 to 8 bytes in length. Optionally, -FIND can be
used in conjunction with REPLACE or DELETE (as described below).
8.6.1.8
-FIND...,DELETE
If the DELETE form of the -FIND option is used, any matching sequences will be
removed. This function should be used with extreme caution and is not normally
recommended for removal of executable code.
8.6.1.9
-FIND...,REPLACE
If the REPLACE form of the -FIND option is used, any matching sequences will be
replaced, or partially replaced, with new codes. The usage for this sub-option is:
-FIND...,REPLACE=Code [mMask]
where:
• Code is a little endian hexadecimal code to replace the sequences that match the
-FIND criteria.
• Mask is an optional bit mask to specify which bits within Code will replace the
code sequence that has been matched. This may be useful if, for example, it is
only necessary to modify 4 bits within a 16-bit instruction. The remaining 12 bits
can masked and be left unchanged.
DS52053B-page 308
2012 Microchip Technology Inc.
Utilities
8.6.1.10
-FORMAT
The -FORMAT option can be used to specify a particular variant of INHX format or
adjust maximum record length. The usage of this option is:
-FORMAT=Type [,Length]
where:
• Type specifies a particular INHX format to generate.
• Length is optional and sets the maximum number of bytes per data record. A
valid length is between 1 and 16, with 16 being the default.
Consider the case of a bootloader trying to download an INHX32 file which fails
because it cannot process the extended address records which are part of the INHX32
standard. You know that this bootloader can only program data addressed within the
range 0 to 64k, and that any data in the HEX file outside of this range can be safely
disregarded. In this case, by generating the HEX file in INHX8M format the operation
might succeed. The HEXMATE option to do this would be -FORMAT=INHX8M.
Now consider if the same bootloader also required every data record to contain eight
bytes of data, no more, no less. This is possible by combining the -FORMAT with -FILL
options. Appropriate use of -FILL can ensure that there are no gaps in the data for the
address range being programmed. This will satisfy the minimum data length requirement. To set the maximum length of data records to eight bytes, just modify the
previous option to become -FORMAT=INHX8M,8.
The possible types that are supported by this option are listed in Table 8-10. Note that
INHX032 is not an actual INHX format. Selection of this type generates an INHX32 file
but will also initialize the upper address information to zero. This is a requirement of
some device programmers.
TABLE 8-10:
INHX TYPES USED IN -FORMAT OPTION
Type
Description
INHX8M
Cannot program addresses beyond 64K
INHX32
Can program addresses beyond 64K with extended linear address records
INHX032
INHX32 with initialization of upper address to zero
8.6.1.11
-HELP
Using -HELP will list all HEXMATE options. By entering another HEXMATE option as a
parameter of -HELP will show a detailed help message for the given option. For
example:
-HELP=string
will show additional help for the -STRING HEXMATE option.
8.6.1.12
-LOGFILE
The -LOGFILE option saves HEX file statistics to the named file. For example:
-LOGFILE=output.log
will analyze the HEX file that HEXMATE is generating and save a report to a file named
output.log.
2012 Microchip Technology Inc.
DS52053B-page 309
MPLAB® XC8 C Compiler User’s Guide
8.6.1.13
-MASK
Use this option to logically AND a memory range with a particular bitmask. This is used
to ensure that the unimplemented bits in program words (if any) are left blank. The
usage of this option is as follows:
-MASK=hexcode@start-end
Where hexcode is a hexadecimal value that will be ANDed with data within the start
to end address range. Multibyte mask values can be entered in little endian byte order.
8.6.1.14
-OFILE
The generated Intel HEX output will be created in this file. For example:
-Oprogram.hex
will save the resultant output to program.hex. The output file can take the same name
as one of its input files, but by doing so it will replace the input file entirely.
8.6.1.15
-SERIAL
This option will store a particular HEX value at a fixed address. The usage of this option
is:
-SERIAL=Code [+/-Increment]@Address [+/-Interval][rRepetitions]
where:
• Code is a hexadecimal value to store and is entered in little endian byte order.
• Increment is optional and allows the value of Code to change by this value with
each repetition (if requested).
• Address is the location to store this code, or the first repetition thereof.
• Interval is optional and specifies the address shift per repetition of this code.
• Repetitions is optional and specifies the number of times to repeat this code.
For example:
-SERIAL=000001@EFFE
will store HEX code 00001h to address EFFEh.
Another example:
-SERIAL=0000+2@1000+10r5
will store 5 codes, beginning with value 0000 at address 1000h. Subsequent codes
will appear at address intervals of +10h and the code value will change in increments
of +2h.
8.6.1.16
-SIZE
Using the -SIZE option will report the number of bytes of data within the resultant HEX
image to standard output. The size will also be recorded in the log file if one has been
requested.
DS52053B-page 310
2012 Microchip Technology Inc.
Utilities
8.6.1.17
-STRING
The -STRING option will embed an ASCII string at a fixed address. The usage of this
option is:
-STRING@Address [tCode]=”Text”
where:
• Address is the location to store this string.
• Code is optional and allows a byte sequence to trail each byte in the string. This
can allow the bytes of the string to be encoded within an instruction.
• Text is the string to convert to ASCII and embed.
For example:
-STRING@1000=”My favorite string”
will store the ASCII data for the string, My favorite string (including the nul
character terminator) at address 1000h.
And again:
-STRING@1000t34=”My favorite string”
will store the same string with every byte in the string being trailed with the HEX code
34h.
8.6.1.18
-STRPACK
This option performs the same function as -STRING but with two important differences.
Firstly, only the lower seven bits from each character are stored. Pairs of 7 bit characters are then concatenated and stored as a 14 bit word rather than in separate bytes.
This is known as string packing. This is usually only useful for devices where program
space is addressed as 14 bit words (PIC10/12/16 devices). The second difference is
that -STRING’s t specifier is not applicable with the -STRPACK option.
2012 Microchip Technology Inc.
DS52053B-page 311
MPLAB® XC8 C Compiler User’s Guide
NOTES:
DS52053B-page 312
2012 Microchip Technology Inc.
MPLAB® XC8 C COMPILER
USER’S GUIDE
Appendix A. Library Functions
The functions and preprocessor macros within the standard compiler library are alphabetically listed in this chapter.
The synopsis indicates the header file in which a declaration or definition for function
or macro is found. It also shows the function prototype for functions, or the equivalent
prototype for macros.
__CONFIG (BASELINE & MID-RANGE DEVICES)
Synopsis
#include
__CONFIG(data)
Description
This macro is used to program the configuration fuses that set the device’s operating
modes.
The macro assumes the argument is a16-bit value, which will be used to program the
configuration bits.
16-bit masks have been defined to describe each programmable attribute available on
each device. These masks can be found in the chip-specific header files included via
.
Multiple attributes can be selected by ANDing them together.
Example
#include
__CONFIG(RC & UNPROTECT)
void
main (void)
{
}
See also
__EEPROM_DATA(), __IDLOC(), __IDLOC7(), CONFIG() (PIC18)
2012 Microchip Technology Inc.
DS52053B-page 313
MPLAB® XC8 C Compiler User’s Guide
__CONFIG (PIC18)
Synopsis
#include
__CONFIG(num, data)
Description
This macro is provided for legacy support only. Use the #pragma config for new projects.
This macro is used to program the configuration fuses that set the device’s operating
modes.
The macro accepts the number corresponding to the configuration register it is to program, then the 16-Bit value it is to update it with.
16-bit masks have been defined to describe each programmable attribute available on
each device. These masks can be found in the chip-specific header files included via
.
Multiple attributes can be selected by ANDing them together.
Example
#include
__CONFIG(1,RC & OSCEN)
__CONFIG(2,WDTPS16 & BORV45)
__CONFIG(4, DEBUGEN)
void
main (void)
{
}
See also
__EEPROM_DATA(), __IDLOC(), __IDLOC7(), CONFIG() (baseline &
mid-range devices)
__DELAY_MS, __DELAY_US
Synopsis
__delay_ms(x)
__delay_us(x)
// request a delay in milliseconds
// request a delay in microseconds
Description
As it is often more convenient request a delay in time-based terms rather than in cycle
counts, the macros __delay_ms(x) and __delay_us(x) are provided. These macros simply wrap around _delay(n) and convert the time based request into instruction
cycles based on the system frequency. In order to achieve this, these macros require
the prior definition of preprocessor symbol _XTAL_FREQ. This symbol should be
defined as the oscillator frequency (in Hertz) used by the system.
An error will result if these macros are used without defining oscillator frequency
symbol or if the delay period requested is too large.
See also
_delay()
DS52053B-page 314
2012 Microchip Technology Inc.
Library Functions
__EEPROM_DATA
Synopsis
#include
__EEPROM_DATA(a,b,c,d,e,f,g,h)
Description
This macro is used to store initial values into the device’s EEPROM registers at the time
of programming.
The macro must be given blocks of 8 bytes to write each time it is called, and can be
called repeatedly to store multiple blocks.
__EEPROM_DATA() will begin writing to EEPROM address zero, and will
auto-increment the address written to by 8, each time it is used.
Example
#include
__EEPROM_DATA(0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07)
__EEPROM_DATA(0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F)
void
main (void)
{
}
See also
__CONFIG()
__IDLOC
Synopsis
#include
__IDLOC(x)
Description
This macro is provided for legacy support only. Use the #pragma config for new projects.
This macro places data into the device’s special locations outside of addressable
memory reserved for ID. This would be useful for storage of serial numbers etc.
The macro will attempt to write 4 nibbles of data to the 4 locations reserved for ID
purposes.
Example
#include
/* will store 1, 5, F and 0 in the ID registers */
__IDLOC(15F0);
void
main (void)
{
}
2012 Microchip Technology Inc.
DS52053B-page 315
MPLAB® XC8 C Compiler User’s Guide
See also
__IDLOC7(), __CONFIG()
__IDLOC7
Synopsis
#include
__IDLOC7(a,b,c,d)
Description
This macro is provided for legacy support only. Use the #pragma config for new projects.
This macro places data into the device’s special locations outside of addressable
memory reserved for ID. This would be useful for storage of serial numbers etc.
The macro will attempt to write 7 bits of data to each of the 4 locations reserved for ID
purposes.
Example
#include
/* will store 7Fh, 70, 1 and 5Ah in the ID registers */
__IDLOC(0x7F,70,1,0x5A);
void
main (void)
{
}
Note
Not all devices permit 7 bit programming of the ID locations. Refer to the device data
sheet to see whether this macro can be used on your particular device.
See also
__IDLOC(), __CONFIG()
_DELAY()
Synopsis
#include
void _delay(unsigned long cycles);
Description
This is an inline function that is expanded by the code generator. When called, this routine expands to an inline assembly delay sequence. The sequence will consist of code
that delays for the number of instruction cycles that is specified as the argument. The
argument must be a literal constant.
An error will result if the delay period requested is too large (approximately 50,659,000
instructions). For very large delays, call this function multiple times.
DS52053B-page 316
2012 Microchip Technology Inc.
Library Functions
Example
#include
void
main (void)
{
control |= 0x80;
_delay(10);
// delay for 10 cycles
control &= 0x7F;
}
See Also
_delay3(), __delay_us(), __delay_ms()
_DELAY3()
Synopsis
#include
void _delay3(unsigned char cycles);
Description
This is an inline function that is expanded by the code generator. When called, this routine expands to an inline assembly delay sequence.The sequence will consist of code
that delays for 3 times the number of cycles that is specified as argument. The argument can be a byte-sized constant or variable.
Example
#include
void
main (void)
{
control |= 0x80;
_delay(10);
// delay for 30 cycles
control &= 0x7F;
}
See Also
_delay
ABS
Synopsis
#include
int abs (int j)
Description
The abs() function returns the absolute value of j.
2012 Microchip Technology Inc.
DS52053B-page 317
MPLAB® XC8 C Compiler User’s Guide
Example
#include
#include
void
main (void)
{
int a = -5;
printf(“The absolute value of %d is %d\n”, a, abs(a));
}
See Also
labs(), fabs()
Return Value
The absolute value of j.
ACOS
Synopsis
#include
double acos (double f)
Description
The acos() function implements the inverse of cos(); i.e., it is passed a value in the
range -1 to +1, and returns an angle in radians whose cosine is equal to that value.
Example
#include
#include
/* Print acos() values for -1 to 1 in degrees. */
void
main (void)
{
float i, a;
for(i = -1.0; i < 1.0 ; i += 0.1) {
a = acos(i)*180.0/3.141592;
printf(“acos(%f) = %f degrees\n”, i, a);
}
}
See Also
sin(), cos(), tan(), asin(), atan(), atan2()
Return Value
An angle in radians, in the range 0 to
DS52053B-page 318
2012 Microchip Technology Inc.
Library Functions
ASCTIME
Synopsis
#include
char * asctime (struct tm * t)
Description
The asctime() function takes the time broken down into the struct tm structure,
pointed to by its argument, and returns a 26 character string describing the current date
and time in the format:
Sun Sep 16 01:03:52 1973\n\0
Note the newline at the end of the string. The width of each field in the string is fixed.
The example gets the current time, converts it to a struct tm with localtime(), it
then converts this to ASCII and prints it. The time() function will need to be provided
by the user (see time() for details).
Example
#include
#include
void
main (void)
{
time_t clock;
struct tm * tp;
time(&clock);
tp = localtime(&clock);
printf(“%s”, asctime(tp));
}
See Also
ctime(), gmtime(), localtime(), time()
Return Value
A pointer to the string.
Note
The example will require the user to provide the time() routine as it cannot be
supplied with the compiler. See time() for more details.
ASIN
Synopsis
#include
double asin (double f)
Description
The asin() function implements the converse of sin(); i.e., it is passed a value in the
range -1 to +1, and returns an angle in radians whose sine is equal to that value.
2012 Microchip Technology Inc.
DS52053B-page 319
MPLAB® XC8 C Compiler User’s Guide
Example
#include
#include
void
main (void)
{
float i, a;
for(i = -1.0; i < 1.0 ; i += 0.1) {
a = asin(i)*180.0/3.141592;
printf(“asin(%f) = %f degrees\n”, i, a);
}
}
See Also
sin(), cos(), tan(), acos(), atan(), atan2()
Return Value
An angle in radians, in the range -
ASSERT
Synopsis
#include
void assert (int e)
Description
This macro is used for debugging purposes; the basic method of usage is to place
assertions liberally throughout your code at points where correct operation of the code
depends upon certain conditions being true initially. An assert() routine may be used
to ensure at run time that an assumption holds true. For example, the following
statement asserts that tp is not equal to NULL:
assert(tp);
If at run time the expression evaluates to false, the program will abort with a message
identifying the source file and line number of the assertion, and the expression used as
an argument to it. A fuller discussion of the uses of assert() is impossible in limited
space, but it is closely linked to methods of proving program correctness.
The assert() macro depends on the implementation of the function _fassert().
By default this prints information using printf(). This routine should be inspected to
ensure it meets your application needs. Include the source file containing this function,
even if you do not modify it, into your project and then rebuild. The _fassert()
function is not built into any library file.
Example
#include
void
ptrfunc (struct xyz * tp)
{
assert(tp != 0);
}
Note
The underlying routine _fassert(...) will need to be implemented by the user.
DS52053B-page 320
2012 Microchip Technology Inc.
Library Functions
ATAN
Synopsis
#include
double atan (double x)
Description
This function returns the arc tangent of its argument; i.e., it returns an angle ‘e’ in the
range - .
Example
#include
#include
void
main (void)
{
printf(“atan(%f) is %f\n”, 1.5, atan(1.5));
}
See Also
sin(), cos(), tan(), asin(), acos(), atan2()
Return Value
The arc tangent of its argument.
ATAN2
Synopsis
#include
double atan2 (double x, double x)
Description
This function returns the arc tangent of y/x.
Example
#include
#include
void
main (void)
{
printf(“atan2(%f, %f) is %f\n”, 10.0, -10.0, atan2(10.0, -10.0));
}
See Also
sin(), cos(), tan(), asin(), acos(), atan()
Return Value
The arc tangent of y/x.
2012 Microchip Technology Inc.
DS52053B-page 321
MPLAB® XC8 C Compiler User’s Guide
ATOF
Synopsis
#include
double atof (const char * s)
Description
The atof() function scans the character string passed to it, skipping leading blanks. It
then converts an ASCII representation of a number to a double. The number may be in
decimal, normal floating point or scientific notation.
Example
#include
#include
void
main (void)
{
char buf[80];
double i;
gets(buf);
i = atof(buf);
printf(“Read %s: converted to %f\n”, buf, i);
}
See Also
atoi(), atol(), strtod()
Return Value
A double precision floating-point number. If no number is found in the string, 0.0 will be
returned.
ATOI
Synopsis
#include
int atoi (const char * s)
Description
The atoi() function scans the character string passed to it, skipping leading blanks
and reading an optional sign. It then converts an ASCII representation of a decimal
number to an integer.
DS52053B-page 322
2012 Microchip Technology Inc.
Library Functions
Example
#include
#include
void
main (void)
{
char buf[80];
int i;
gets(buf);
i = atoi(buf);
printf(“Read %s: converted to %d\n”, buf, i);
}
See Also
xtoi(), atof(), atol()
Return Value
A signed integer. If no number is found in the string, 0 will be returned.
ATOL
Synopsis
#include
long atol (const char * s)
Description
The atol() function scans the character string passed to it, skipping leading blanks. It
then converts an ASCII representation of a decimal number to a long integer.
Example
#include
#include
void
main (void)
{
char buf[80];
long i;
gets(buf);
i = atol(buf);
printf(“Read %s: converted to %ld\n”, buf, i);
}
See Also
atoi(), atof()
Return Value
A long integer. If no number is found in the string, 0 will be returned.
2012 Microchip Technology Inc.
DS52053B-page 323
MPLAB® XC8 C Compiler User’s Guide
BSEARCH
Synopsis
#include
void * bsearch (const void * key, void * base, size_t n_memb,
size_t size, int (*compar)(const void *, const void *))
Description
The bsearch() function searches a sorted array for an element matching a particular
key. It uses a binary search algorithm, calling the function pointed to by compar to
compare elements in the array.
Example
#include
#include
#include
struct value {
char name[40];
int value;
} values[100];
int
val_cmp (const void * p1, const void * p2)
{
return strcmp(((const struct value *)p1)->name,
((const struct value *)p2)->name);
}
void
main (void)
{
char inbuf[80];
int i;
struct value * vp;
i = 0;
while(gets(inbuf)) {
sscanf(inbuf,”%s %d”, values[i].name, &values[i].value);
i++;
}
qsort(values, i, sizeof values[0], val_cmp);
vp = bsearch(“fred”, values, i, sizeof values[0], val_cmp);
if(!vp)
printf(“Item ’fred’ was not found\n”);
else
printf(“Item ’fred’ has value %d\n”, vp->value);
}
See Also
qsort()
Return Value
A pointer to the matched array element (if there is more than one matching element,
any of these may be returned). If no match is found, a null is returned.
Note
The comparison function must have the correct prototype.
DS52053B-page 324
2012 Microchip Technology Inc.
Library Functions
CEIL
Synopsis
#include
double ceil (double f)
Description
This routine returns the smallest whole number not less than f.
Example
#include
#include
void
main (void)
{
double j;
scanf(“%lf” &j);
printf(“The ceiling of %lf is %lf\n”, j, ceil(j));
}
CGETS
Synopsis
#include
char * cgets (char * s)
Description
The cgets() function will read one line of input from the console into the buffer passed
as an argument. It does so by repeated calls to getche(). As characters are read,
they are buffered, with backspace deleting the previously typed character, and ctrl-U
deleting the entire line typed so far. Other characters are placed in the buffer, with a
carriage return or line feed (newline) terminating the function. The collected string is
null terminated.
Example
#include
#include
char buffer[80];
void
main (void)
{
for(;;) {
cgets(buffer);
if(strcmp(buffer, “exit” == 0)
break;
cputs(“Type ’exit’ to finish\n”);
}
}
2012 Microchip Technology Inc.
DS52053B-page 325
MPLAB® XC8 C Compiler User’s Guide
See Also
getch(), getche(), putch(), cputs()
Return Value
The return value is the character passed as the sole argument.
CLRWDT
Synopsis
#include
CLRWDT();
Description
This macro is used to clear the device’s internal watchdog timer.
Example
#include
void
main (void)
{
WDTCON=1;
/* enable the WDT */
CLRWDT();
}
COS
Synopsis
#include
double cos (double f)
Description
This function yields the cosine of its argument, which is an angle in radians. The cosine
is calculated by expansion of a polynomial series approximation.
Example
#include
#include
#define C 3.141592/180.0
void
main (void)
{
double i;
for(i = 0 ; i > 5);
revision_no = (unsigned char)(id_value & 0x1F);
}
See Also
flash_read(), config_read()
Return Value
device_id_read() returns the 16-Bit factory-programmed device id code used to
identify the device type and its revision number.
Note
The device_id_read() is applicable only to those devices which are capable of
reading their own program memory.
DI, EI
Synopsis
#include
void ei (void)
void di (void)
Description
The di() and ei() routines disable and re-enable interrupts respectively. These are
implemented as macros. The example shows the use of ei() and di() around access
to a long variable that is modified during an interrupt. If this was not done, it would be
possible to return an incorrect value, if the interrupt occurred between accesses to
successive words of the count value.
The ei() macro should never be called in an interrupt function, and there is no need
to call di() in an interrupt function.
2012 Microchip Technology Inc.
DS52053B-page 329
MPLAB® XC8 C Compiler User’s Guide
Example
#include
long count;
void
interrupt tick (void)
{
count++;
}
long
getticks (void)
{
long val;
/* Disable interrupts around access
to count, to ensure consistency.*/
di();
val = count;
ei();
return val;
}
DIV
Synopsis
#include
div_t div (int numer, int denom)
Description
The div() function computes the quotient and remainder of the numerator divided by
the denominator.
Example
#include
#include
void
main (void)
{
div_t x;
x = div(12345, 66);
printf(“quotient = %d, remainder = %d\n”, x.quot, x.rem);
}
See Also
udiv(), ldiv(), uldiv()
Return Value
Returns the quotient and remainder into the div_t structure.
EEPROM ROUTINES
Description
These functions are now supplied in the peripheral library. See the peripheral library
documentation for full information on this library function.
DS52053B-page 330
2012 Microchip Technology Inc.
Library Functions
EVAL_POLY
Synopsis
#include
double eval_poly (double x, const double * d, int n)
Description
The eval_poly() function evaluates a polynomial, whose coefficients are contained in
the array d, at x, for example:
y = x*x*d2 + x*d1 + d0.
The order of the polynomial is passed in n.
Example
#include
#include
void
main (void)
{
double x, y;
double d[3] = {1.1, 3.5, 2.7};
x = 2.2;
y = eval_poly(x, d, 2);
printf(“The polynomial evaluated at %f is %f\n”, x, y);
}
Return Value
A double value, being the polynomial evaluated at x.
EXP
Synopsis
#include
double exp (double f)
Description
The exp() routine returns the exponential function of its argument; i.e., ‘e’ to the power
of ‘f’.
Example
#include
#include
void
main (void)
{
double f;
for(f = 0.0 ; f tm_year+1900);
}
See Also
ctime(), asctime(), time(), localtime()
Return Value
Returns a structure of type tm.
2012 Microchip Technology Inc.
DS52053B-page 337
MPLAB® XC8 C Compiler User’s Guide
Note
The example will require the user to provide the time() routine as one cannot be
supplied with the compiler. See time() for more detail.
ISALNUM, ISALPHA, ISDIGIT, ISLOWER, ET. AL.
Synopsis
#include
int
int
int
int
int
int
int
int
int
int
int
int
isalnum (char
isalpha (char
isascii (char
iscntrl (char
isdigit (char
islower (char
isprint (char
isgraph (char
ispunct (char
isspace (char
isupper (char
isxdigit(char
c)
c)
c)
c)
c)
c)
c)
c)
c)
c)
c)
c)
Description
These macros, defined in ctype.h, test the supplied character for membership in one
of several overlapping groups of characters. Note that all except isascii() are
defined for c, if isascii(c) is true or if c = EOF.
isalnum(c)
isalpha(c)
isascii(c)
iscntrl(c)
isdigit(c)
islower(c)
isprint(c)
isgraph(c)
ispunct(c)
isspace(c)
isupper(c)
isxdigit(c)
c
c
c
c
c
c
c
c
c
c
c
c
is in 0-9 or a-z or A-Z
is in A-Z or a-z
is a 7 bit ascii character
is a control character
is a decimal digit
is in a-z
is a printing char
is a non-space printable character
is not alphanumeric
is a space, tab or newline
is in A-Z
is in 0-9 or a-f or A-F
Example
#include
#include
void
main (void)
{
char buf[80];
int i;
gets(buf);
i = 0;
while(isalnum(buf[i]))
i++;
buf[i] = 0;
printf("’%s’ is the word\n", buf);
}
DS52053B-page 338
2012 Microchip Technology Inc.
Library Functions
See Also
toupper(), tolower(), toascii()
ISDIG
Synopsis
#include
int isdig (int c)
Description
The isdig() function tests the input character c to see if is a decimal digit (0 – 9) and
returns true is this is the case; false otherwise.
Example
#include
void
main (void)
{
char buf[] = "1998a";
if(isdig(buf[0]))
printf(" type detected\n");
}
See Also
isdigit() (listed under isalnum())
Return Value
Zero if the character is a decimal digit; a non-zero value otherwise.
ITOA
Synopsis
#include
char * itoa (char * buf, int val, int base)
Description
The function itoa converts the contents of val into a string which is stored into buf.
The conversion is performed according to the radix specified in base. buf is assumed
to reference a buffer which has sufficient space allocated to it.
Example
#include
#include
void
main (void)
{
char buf[10];
itoa(buf, 1234, 16);
printf("The buffer holds %s\n", buf);
}
See Also
strtol(), utoa(), ltoa(), ultoa()
2012 Microchip Technology Inc.
DS52053B-page 339
MPLAB® XC8 C Compiler User’s Guide
Return Value
This routine returns a copy of the buffer into which the result is written.
LABS
Synopsis
#include
int labs (long int j)
Description
The labs() function returns the absolute value of long value j.
Example
#include
#include
void
main (void)
{
long int a = -5;
printf("The absolute value of %ld is %ld\n", a, labs(a));
}
See Also
abs()
Return Value
The absolute value of j.
LDEXP
Synopsis
#include
double ldexp (double f, int i)
Description
The ldexp() function performs the inverse of frexp() operation; the integer i is
added to the exponent of the floating-point f and the resultant returned.
Example
#include
#include
void
main (void)
{
double f;
f = ldexp(1.0, 10);
printf("1.0 * 2^10 = %f\n", f);
}
See Also
frexp()
DS52053B-page 340
2012 Microchip Technology Inc.
Library Functions
Return Value
The return value is the integer i added to the exponent of the floating-point value f.
LDIV
Synopsis
#include
ldiv_t ldiv (long number, long denom)
Description
The ldiv() routine divides the numerator by the denominator, computing the quotient
and the remainder. The sign of the quotient is the same as that of the mathematical
quotient. Its absolute value is the largest integer which is less than the absolute value
of the mathematical quotient.
The ldiv() function is similar to the div() function, the difference being that the
arguments and the members of the returned structure are all of type long int.
Example
#include
#include
void
main (void)
{
ldiv_t lt;
lt = ldiv(1234567, 12345);
printf("Quotient = %ld, remainder = %ld\n", lt.quot, lt.rem);
}
See Also
div(), uldiv(), udiv()
Return Value
Returns a structure of type ldiv_t
LOCALTIME
Synopsis
#include
struct tm * localtime (time_t * t)
Description
The localtime() function converts the time pointed to by t which is in seconds since
00:00:00 on Jan 1, 1970, into a broken down time stored in a structure as defined in
time.h. The routine localtime() takes into account the contents of the global integer
time_zone. This should contain the number of minutes that the local time zone is
westward of Greenwich. On systems where it is not possible to predetermine this value,
localtime() will return the same result as gmtime().
2012 Microchip Technology Inc.
DS52053B-page 341
MPLAB® XC8 C Compiler User’s Guide
Example
#include
#include
char * wday[] = {
"Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"
};
void
main (void)
{
time_t clock;
struct tm * tp;
time(&clock);
tp = localtime(&clock);
printf("Today is %s\n", wday[tp->tm_wday]);
}
See Also
ctime(), asctime(), time()
Return Value
Returns a structure of type tm.
Note
The example will require the user to provide the time() routine as one cannot be
supplied with the compiler. See time() for more detail.
LOG, LOG10
Synopsis
#include
double log (double f)
double log10 (double f)
Description
The log() function returns the natural logarithm of f. The function log10() returns the
logarithm to base 10 of f.
Example
#include
#include
void
main (void)
{
double f;
for(f = 1.0 ; f 0)
printf("Greater than\n");
else
printf("Equal\n");
}
2012 Microchip Technology Inc.
DS52053B-page 345
MPLAB® XC8 C Compiler User’s Guide
See Also
strncpy(), strncmp(), strchr(), memset(), memchr()
Return Value
Returns negative one, zero or one, depending on whether s1 points to string which is
less than, equal to or greater than the string pointed to by s2 in the collating sequence.
MEMCPY
Synopsis
#include
void * memcpy (void * d, const void * s, size_t n)
Description
The memcpy() function copies n bytes of memory starting from the location pointed to
by s to the block of memory pointed to by d. The result of copying overlapping blocks
is undefined. The memcpy() function differs from strcpy() in that it copies a specified
number of bytes, rather than all bytes up to a null terminator.
Example
#include
#include
void
main (void)
{
char buf[80];
memset(buf, 0, sizeof buf);
memcpy(buf, "A partial string", 10);
printf("buf = ’%s’\n", buf);
}
See Also
strncpy(), strncmp(), strchr(), memset()
Return Value
The memcpy() routine returns its first argument.
MEMMOVE
Synopsis
#include
void * memmove (void * s1, const void * s2, size_t n)
Description
The memmove() function is similar to the function memcpy() except copying of
overlapping blocks is handled correctly. That is, it will copy forwards or backwards as
appropriate to correctly copy one block to another that overlaps it.
See Also
strncpy(), strncmp(), strchr(), memcpy()
DS52053B-page 346
2012 Microchip Technology Inc.
Library Functions
Return Value
The function memmove() returns its first argument.
MEMSET
Synopsis
#include
void * memset (void * s, int c, size_t n)
Description
The memset() function fills n bytes of memory starting at the location pointed to by s
with the byte c.
Example
#include
#include
void
main (void)
{
char abuf[20];
strcpy(abuf, "This is a string";
memset(abuf, ’x’, 5);
printf("buf = ’%s’\n", abuf);
}
See Also
strncpy(), strncmp(), strchr(), memcpy(), memchr()
MKTIME
Synopsis
#include
time_t mktime (struct tm * tmptr)
Description
The mktime() function converts and returns the local calendar time referenced by the
tm structure tmptr into a time being the number of seconds passed since Jan 1, 1970,
or returns -1 if the time cannot be represented.
2012 Microchip Technology Inc.
DS52053B-page 347
MPLAB® XC8 C Compiler User’s Guide
Example
#include
#include
void
main (void)
{
struct tm birthday;
birthday.tm_year = 83;
// the 5th of May 1983
birthday.tm_mon = 5;
birthday.tm_mday = 5;
birthday.tm_hour = birthday.tm_min = birthday.tm_sec = 0;
printf("you were born approximately %ld seconds after the unix
epoch\n",
mktime(&birthday));
}
See Also
ctime(), asctime()
Return Value
The time contained in the tm structure represented as the number of seconds since the
1970 Epoch, or -1 if this time cannot be represented.
MODF
Synopsis
#include
double modf (double value, double * iptr)
Description
The modf() function splits the argument value into integral and fractional parts, each
having the same sign as value. For example, -3.17 would be split into the integral part
(-3) and the fractional part (-0.17).
The integral part is stored as a double in the object pointed to by iptr.
Example
#include
#include
void
main (void)
{
double i_val, f_val;
f_val = modf( -3.17, &i_val);
}
Return Value
The signed fractional part of value.
DS52053B-page 348
2012 Microchip Technology Inc.
Library Functions
NOP
Synopsis
#include
NOP();
Description
Execute NOP instruction here. This is often useful to fine tune delays or create a handle
for breakpoints. The NOP instruction is sometimes required during some sensitive
sequences in hardware.
Example
#include
void
crude_delay(unsigned char x) {
while(x--){
NOP(); /* Do nothing for 3 cycles */
NOP();
NOP();
}
}
2012 Microchip Technology Inc.
DS52053B-page 349
MPLAB® XC8 C Compiler User’s Guide
POW
Synopsis
#include
double pow (double f, double p)
Description
The pow() function raises its first argument, f, to the power p.
Example
#include
#include
void
main (void)
{
double f;
for(f = 1.0 ; f "hello"
#define DEBUG
#endif
(127) bad syntax for defined() in #[el]if
(Preprocessor)
The defined() pseudo-function in a preprocessor expression requires its argument
to be a single name. The name must start with a letter and should be enclosed in
parentheses, for example:
/* oops -- defined expects a name, not an expression */
#if defined(a&b)
input = read();
#endif
(128) illegal operator in #if
(Preprocessor)
A #if expression has an illegal operator. Check for correct syntax, for example:
#if FOO = 6
/* oops -- should that be: #if FOO == 5 ? */
(129) unexpected "\" in #if
(Preprocessor)
The backslash is incorrect in the #if statement, for example:
#if FOO == \34
#define BIG
#endif
(130) unknown type "*" in #[el]if sizeof()
(Preprocessor)
An unknown type was used in a preprocessor sizeof(). The preprocessor can only
evaluate sizeof() with basic types, or pointers to basic types, for example:
#if sizeof(unt) == 2
i = 0xFFFF;
#endif
/* should be: #if sizeof(int) == 2 */
(131) illegal type combination in #[el]if sizeof()
(Preprocessor)
The preprocessor found an illegal type combination in the argument to sizeof() in a
#if expression, for example:
/* To sign, or not to sign, that is the error. */
#if sizeof(signed unsigned int) == 2
i = 0xFFFF;
#endif
2012 Microchip Technology Inc.
DS52053B-page 381
MPLAB® XC8 C Compiler User’s Guide
(132) no type specified in #[el]if sizeof()
(Preprocessor)
Sizeof() was used in a preprocessor #if expression, but no type was specified. The
argument to sizeof() in a preprocessor expression must be a valid simple type, or
pointer to a simple type, for example:
#if sizeof()
i = 0;
#endif
/* oops -- size of what? */
(133) unknown type code (0x*) in #[el]if sizeof()
(Preprocessor)
The preprocessor has made an internal error in evaluating a sizeof() expression.
Check for a malformed type specifier. This is an internal error. Contact Microchip
Technical Support with details.
(134) syntax error in #[el]if sizeof()
(Preprocessor)
The preprocessor found a syntax error in the argument to sizeof in a #if expression.
Probable causes are mismatched parentheses and similar things, for example:
#if sizeof(int == 2)
i = 0xFFFF;
#endif
// oops - should be: #if sizeof(int) == 2
(135) unknown operator (*) in #if
(Preprocessor)
The preprocessor has tried to evaluate an expression with an operator it does not
understand. This is an internal error. Contact Microchip Technical Support with details.
(137) strange character "*" after ##
(Preprocessor)
A character has been seen after the token catenation operator ## that is neither a letter
nor a digit. Since the result of this operator must be a legal token, the operands must
be tokens containing only letters and digits, for example:
/* the ’ character will not lead to a valid token */
#define cc(a, b) a ## ’b
(138) strange character (*) after ##
(Preprocessor)
An unprintable character has been seen after the token catenation operator ## that is
neither a letter nor a digit. Since the result of this operator must be a legal token, the
operands must be tokens containing only letters and digits, for example:
/* the ’ character will not lead to a valid token */
#define cc(a, b) a ## ’b
(139) end of file in comment
(Preprocessor)
End of file was encountered inside a comment. Check for a missing closing comment
flag, for example:
/* Here the comment begins. I’m not sure where I end, though
}
(140) can’t open * file "*": *
(Driver, Preprocessor, Code Generator, Assembler)
The command file specified could not be opened for reading. Confirm the spelling and
path of the file specified on the command line, for example:
xc8 @communds
should that be:
xc8 @commands
DS52053B-page 382
2012 Microchip Technology Inc.
Error and Warning Messages
(141) can’t open * file "*": *
(Any)
An output file could not be created. Confirm the spelling and path of the file specified
on the command line.
(144) too many nested #if blocks
(Preprocessor)
#if , #ifdef etc. blocks may only be nested to a maximum of 32.
(146) #include filename too long
(Preprocessor)
A filename constructed while looking for an include file has exceeded the length of an
internal buffer. Since this buffer is 4096 bytes long, this is unlikely to happen.
(147) too many #include directories specified
(Preprocessor)
A maximum of 7 directories may be specified for the preprocessor to search for include
files. The number of directories specified with the driver is too great.
(148) too many arguments for preprocessor macro
(Preprocessor)
A macro may only have up to 31 parameters, as per the C Standard.
(149) preprocessor macro work area overflow
(Preprocessor)
The total length of a macro expansion has exceeded the size of an internal table. This
table is normally 32768 bytes long. Thus any macro expansion must not expand into a
total of more than 32K bytes.
(150) illegal "__" preprocessor macro "*"
(Preprocessor)
This is an internal compiler error. Contact Microchip Technical Support with details.
(151) too many arguments in preprocessor macro expansion
(Preprocessor)
There were too many arguments supplied in a macro invocation. The maximum number allowed is 31.
(152) bad dp/nargs in openpar(): c = *
(Preprocessor)
This is an internal compiler error. Contact Microchip Technical Support with details.
(153) out of space in preprocessor macro * argument expansion
(Preprocessor)
A macro argument has exceeded the length of an internal buffer. This buffer is normally
4096 bytes long.
(155) work buffer overflow concatenating "*"
(Preprocessor)
This is an internal compiler error. Contact Microchip Technical Support with details.
(156) work buffer "*" overflow
(Preprocessor)
This is an internal compiler error. Contact Microchip Technical Support with details.
(157) can’t allocate * bytes of memory
(Code Generator, Assembler)
This is an internal compiler error. Contact Microchip Technical Support with details.
(158) invalid disable in preprocessor macro "*"
(Preprocessor)
This is an internal compiler error. Contact Microchip Technical Support with details.
(159) too many calls to unget()
(Preprocessor)
This is an internal compiler error. Contact Microchip Technical Support with details.
2012 Microchip Technology Inc.
DS52053B-page 383
MPLAB® XC8 C Compiler User’s Guide
(161) control line "*" within preprocessor macro expansion
(Preprocessor)
A preprocessor control line (one starting with a #) has been encountered while expanding a macro. This should not happen.
(162) #warning: *
(Preprocessor, Driver)
This warning is either the result of user-defined #warning preprocessor directive or
the driver encountered a problem reading the map file. If the latter, contact Microchip
Technical Support with details
(163) unexpected text in control line ignored
(Preprocessor)
This warning occurs when extra characters appear on the end of a control line. The
extra text will be ignored, but a warning is issued. It is preferable (and in accordance
with Standard C) to enclose the text as a comment, for example:
#if defined(END)
#define NEXT
#endif END
/* END would be better in a comment here */
(164) #include filename "*" was converted to lower case
(Preprocessor)
The #include file name had to be converted to lowercase before it could be opened,
for example:
#include
/* oops -- should be: #include */
(165) #include filename "*" does not match actual name (check upper/lower case) (Preprocessor)
In Windows versions this means the file to be included actually exists and is spelt the
same way as the #include filename; however, the case of each does not exactly
match. For example, specifying #include "code.c" will include Code.c if it is found.
In Linux versions this warning could occur if the file wasn’t found.
(166) too few values specified with option "*"
(Preprocessor)
The list of values to the preprocessor (CPP) -S option is incomplete. This should not
happen if the preprocessor is being invoked by the compiler driver. The values passes
to this option represent the sizes of char , short , int , long , float and double
types.
(167) too many values specified with -S option; "*" unused
Preprocessor)
There were too many values supplied to the -S preprocessor option. See message 166.
(168) unknown option "*"
(Any)
The option given to the component which caused the error is not recognized.
(169) strange character (*) after ##
(Preprocessor)
There is an unexpected character after #.
(170) symbol "*" in undef was never defined
(Preprocessor)
The symbol supplied as argument to #undef was not already defined. This warning
may be disabled with some compilers. This warning can be avoided with code like:
#ifdef SYM
#undef SYM
#endif
DS52053B-page 384
/* only undefine if defined */
2012 Microchip Technology Inc.
Error and Warning Messages
(171) wrong number of preprocessor macro arguments for "*" (* instead of *)
(Preprocessor)
A macro has been invoked with the wrong number of arguments, for example:
#define ADD(a, b) (a+b)
ADD(1, 2, 3)
/* oops -- only two arguments required */
(172) formal parameter expected after #
(Preprocessor)
The stringization operator # (not to be confused with the leading # used for preprocessor control lines) must be followed by a formal macro parameter, for example:
#define str(x) #y
/* oops -- did you mean x instead of y? */
If you need to stringize a token, you will need to define a special macro to do it, for
example:
#define __mkstr__(x) #x
then use __mkstr__(token) wherever you need to convert a token into a string.
(173) undefined symbol "*" in #if, 0 used
(Preprocessor)
A symbol on a #if expression was not a defined preprocessor macro. For the purposes of this expression, its value has been taken as zero. This warning may be disabled with some compilers. Example:
#if FOO+BAR
/* e.g. FOO was never #defined */
#define GOOD
#endif
(174) multi-byte constant "*" isn’t portable
(Preprocessor)
Multi-byte constants are not portable, and in fact will be rejected by later passes of the
compiler, for example:
#if CHAR == ’ab’
#define MULTI
#endif
(175) division by zero in #if; zero result assumed
(Preprocessor)
Inside a #if expression, there is a division by zero which has been treated as yielding
zero, for example:
#if foo/0
int a;
#endif
/* divide by 0: was this what you were intending? */
(176) missing newline
(Preprocessor)
A new line is missing at the end of the line. Each line, including the last line, must have
a new line at the end. This problem is normally introduced by editors.
(177) symbol "*" in -U option was never defined
(Preprocessor)
A macro name specified in a -U option to the preprocessor was not initially defined, and
thus cannot be undefined.
(179) nested comments
(Preprocessor)
This warning is issued when nested comments are found. A nested comment may indicate that a previous closing comment marker is missing or malformed, for example:
output = 0; /* a comment that was left unterminated
flag = TRUE; /* next comment:
hey, where did this line go? */
2012 Microchip Technology Inc.
DS52053B-page 385
MPLAB® XC8 C Compiler User’s Guide
(180) unterminated comment in included file
(Preprocessor)
Comments begun inside an included file must end inside the included file.
(181) non-scalar types can’t be converted to other types
(Parser)
You can’t convert a structure, union or array to another type, for example:
struct TEST test;
struct TEST * sp;
sp = test;
/* oops -- did you mean: sp = &test; ? */
(182) illegal conversion between types
(Parser)
This expression implies a conversion between incompatible types, i.e., a conversion of
a structure type into an integer, for example:
struct LAYOUT layout;
int i;
layout = i;
/* int cannot be converted to struct */
Note that even if a structure only contains an int , for example, it cannot be assigned
to an int variable, and vice versa.
(183) function or function pointer required
(Parser)
Only a function or function pointer can be the subject of a function call, for example:
int a, b, c, d;
a = b(c+d);
/* b is not a function -did you mean a = b*(c+d) ? */
(184) calling an interrupt function is illegal
(Parser)
A function qualified interrupt can’t be called from other functions. It can only be
called by a hardware (or software) interrupt. This is because an interrupt function
has special function entry and exit code that is appropriate only for calling from an interrupt. An interrupt function can call other non-interrupt functions.
(185) function does not take arguments
(Parser, Code Generator)
This function has no parameters, but it is called here with one or more arguments, for
example:
int get_value(void);
void main(void)
{
int input;
input = get_value(6);
/* oops -parameter should not be here */
}
(186) too many function arguments
(Parser)
This function does not accept as many arguments as there are here.
void add(int a, int b);
add(5, 7, input);
/* call has too many arguments */
(187) too few function arguments
(Parser)
This function requires more arguments than are provided in this call, for example:
void add(int a, int b);
add(5);
DS52053B-page 386
/* this call needs more arguments */
2012 Microchip Technology Inc.
Error and Warning Messages
(188) constant expression required
(Parser)
In this context an expression is required that can be evaluated to a constant at compile
time, for example:
int a;
switch(input) {
case a: /* oops!
can’t use variable as part of a case label */
input++;
}
(189) illegal type for array dimension
(Parser)
An array dimension must be either an integral type or an enumerated value.
int array[12.5];
/* oops -- twelve and a half elements, eh? */
(190) illegal type for index expression
(Parser)
An index expression must be either integral or an enumerated value, for example:
int i, array[10];
i = array[3.5];
/* oops -exactly which element do you mean? */
(191) cast type must be scalar or void
(Parser)
A typecast (an abstract type declarator enclosed in parentheses) must denote a type
which is either scalar (i.e., not an array or a structure) or the type void, for example:
lip = (long [])input;
/* oops -- maybe: lip = (long *)input */
(192) undefined identifier "*"
(Parser)
This symbol has been used in the program, but has not been defined or declared.
Check for spelling errors if you think it has been defined.
(193) not a variable identifier "*"
(Parser)
This identifier is not a variable; it may be some other kind of object, i.e., a label.
(194) ")" expected
(Parser)
A closing parenthesis, ), was expected here. This may indicate you have left out this
character in an expression, or you have some other syntax error. The error is flagged
on the line at which the code first starts to make no sense. This may be a statement
following the incomplete expression, for example:
if(a == b
b = 0;
/* the closing parenthesis is missing here */
/* the error is flagged here */
(195) expression syntax
(Parser)
This expression is badly formed and cannot be parsed by the compiler, for example:
a /=% b;
/* oops -- maybe that should be: a /= b; */
(196) struct/union required
(Parser)
A structure or union identifier is required before a dot "." , for example:
int a;
a.b = 9;
/* oops -- a is not a structure */
(197) struct/union member expected
(Parser)
A structure or union member name must follow a dot "." or arrow ("->").
2012 Microchip Technology Inc.
DS52053B-page 387
MPLAB® XC8 C Compiler User’s Guide
(198) undefined struct/union "*"
(Parser)
The specified structure or union tag is undefined, for example:
struct WHAT what;
/* a definition for WHAT was never seen */
(199) logical type required
(Parser)
The expression used as an operand to if, while statements or to boolean operators
like ! and && must be a scalar integral type, for example:
struct FORMAT format;
if(format)
/* this operand must be a scaler type */
format.a = 0;
(200) taking the address of a register variable is illegal
(Parser)
A variable declared register may not have storage allocated for it in memory, and thus
it is illegal to attempt to take the address of it by applying the & operator, for example:
int * proc(register int in)
{
int * ip = ∈
/* oops -- in may not have an address to take */
return ip;
}
(201) taking the address of this object is illegal
(Parser)
The expression which was the operand of the & operator is not one that denotes memory storage (“an lvalue”) and therefore its address can not be defined, for example:
ip = &8;
/* oops -- you can’t take the address of a literal */
(202) only lvalues may be assigned to or modified
(Parser)
Only an lvalue (i.e., an identifier or expression directly denoting addressable storage)
can be assigned to or otherwise modified, for example:
int array[10];
int * ip;
char c;
array = ip;
/* array isn’t a variable,
it can’t be written to */
A typecast does not yield an lvalue, for example:
/* the contents of c cast to int
is only a intermediate value */
(int)c = 1;
However, you can write this using pointers:
*(int *)&c = 1
(203) illegal operation on bit variable
(Parser)
Not all operations on bit variables are supported. This operation is one of those, for
example:
bit
b;
int * ip;
ip = &b; /* oops -cannot take the address of a bit object */
DS52053B-page 388
2012 Microchip Technology Inc.
Error and Warning Messages
(204) void function can’t return a value
(Parser)
A void function cannot return a value. Any return statement should not be followed
by an expression, for example:
void run(void)
{
step();
return 1;
/* either run should not be void, or remove the 1 */
}
(205) integral type required
(Parser)
This operator requires operands that are of integral type only.
(206) illegal use of void expression
(Parser)
A void expression has no value and therefore you can’t use it anywhere an expression
with a value is required, i.e., as an operand to an arithmetic operator.
(207) simple type required for "*"
(Parser)
A simple type (i.e., not an array or structure) is required as an operand to this operator.
(208) operands of "*" not same type
(Parser)
The operands of this operator are of different pointer, for example:
int * ip;
char * cp, * cp2;
cp = flag ? ip : cp2;
/* result of ? : will be int * or char * */
Maybe you meant something like:
cp = flag ? (char *)ip : cp2;
(209) type conflict
(Parser)
The operands of this operator are of incompatible types.
(210) bad size list
(Parser)
This is an internal compiler error. Contact Microchip Technical Support with details.
(211) taking sizeof bit is illegal
(Parser)
It is illegal to use the sizeof operator with the C bit type. When used against a type
the sizeof operator gives the number of bytes required to store an object that type.
Therefore its usage with the bit type make no sense and is an illegal operation.
(212) missing number after pragma "pack"
(Parser)
The pragma pack requires a decimal number as argument. This specifies the alignment of each member within the structure. Use this with caution as some processors
enforce alignment and will not operate correctly if word fetches are made on odd
boundaries, for example:
#pragma pack
/* what is the alignment value */
Maybe you meant something like:
#pragma pack 2
(214) missing number after pragma "interrupt_level"
(Parser)
The pragma interrupt_level requires an argument to indicate the interrupt level.
It will be the value 1 for mid-range devices, or 1 or 2 or PIC18 devices.
2012 Microchip Technology Inc.
DS52053B-page 389
MPLAB® XC8 C Compiler User’s Guide
(215) missing argument to pragma "switch"
(Parser)
The pragma switch requires an argument of auto, direct or simple, for example:
#pragma switch
/* oops -- this requires a switch mode */
maybe you meant something like:
#pragma switch simple
(216) missing argument to pragma "psect"
(Parser)
The pragma psect requires an argument of the form oldname = newname where oldname is an existing psect name known to the compiler, and newname is the desired
new name, for example:
#pragma psect
/* oops -- this requires an psect to redirect */
maybe you meant something like:
#pragma psect text=specialtext
(218) missing name after pragma "inline"
(Parser)
The inline pragma expects the name of a function to follow. The function name must
be recognized by the code generator for it to be expanded; other functions are not
altered, for example:
#pragma inline
/* what is the function name? */
maybe you meant something like:
#pragma inline memcpy
(219) missing name after pragma "printf_check"
(Parser)
The printf_check pragma expects the name of a function to follow. This specifies
printf-style format string checking for the function, for example:
#pragma printf_check
/* what function is to be checked? */
Maybe you meant something like:
#pragma printf_check sprintf
Pragmas for all the standard printf-like function are already contained in .
(220) exponent expected
(Parser)
A floating-point constant must have at least one digit after the e or E., for example:
float f;
f = 1.234e;
/* oops -- what is the exponent? */
(221) hexadecimal digit expected
(Parser)
After 0x should follow at least one of the HEX digits 0-9 and A-F or a-f, for example:
a = 0xg6;
/* oops -- was that meant to be a = 0xf6 ? */
(222) binary digit expected
(Parser)
A binary digit was expected following the 0b format specifier, for example:
i = 0bf000;
/* oops -- f000 is not a base two value */
(223) digit out of range
(Parser, Assembler)
A digit in this number is out of range of the radix for the number, i.e., using the digit 8
in an octal number, or HEX digits A-F in a decimal number. An octal number is denoted
by the digit string commencing with a zero, while a HEX number starts with “0X” or “0x”.
For example:
int a = 058;
/* leading 0 implies octal which has digits 0 - 7 */
DS52053B-page 390
2012 Microchip Technology Inc.
Error and Warning Messages
(224) illegal "#" directive
(Parser)
An illegal # preprocessor has been detected. Likely a directive has been misspelled in
your code somewhere.
(225) missing character in character constant
(Parser)
The character inside the single quotes is missing, for example:
char c = ";
/* the character value of what? */
(226) char const too long
(Parser)
A character constant enclosed in single quotes may not contain more than one character, for example:
c = ’12’;
/* oops -- only one character may be specified */
(227) "." expected after ".."
(Parser)
The only context in which two successive dots may appear is as part of the ellipsis symbol, which must have 3 dots. (An ellipsis is used in function prototypes to indicate a variable number of parameters.)
Either .. was meant to be an ellipsis symbol which would require you to add an extra
dot, or it was meant to be a structure member operator which would require you remove
one dot.
(228) illegal character (*)
(Parser)
This character is illegal in the C code. Valid characters are the letters, digits and those
comprising the acceptable operators, for example:
c = a;
/* oops -- did you mean c = ’a’; ? */
(229) unknown qualifier "*" given to -A
(Parser)
This is an internal compiler error. Contact Microchip Technical Support with details.
(230) missing argument to -A
(Parser)
This is an internal compiler error. Contact Microchip Technical Support with details.
(231) unknown qualifier "*" given to -I
(Parser)
This is an internal compiler error. Contact Microchip Technical Support with details.
(232) missing argument to -I
(Parser)
This is an internal compiler error. Contact Microchip Technical Support with details.
(233) bad -Q option "*"
(Parser)
This is an internal compiler error. Contact Microchip Technical Support with details.
(234) close error
(Parser)
This is an internal compiler error. Contact Microchip Technical Support with details.
(236) simple integer expression required
(Parser)
A simple integral expression is required after the operator @, used to associate an absolute address with a variable, for example:
int address;
char LOCK @ address;
2012 Microchip Technology Inc.
DS52053B-page 391
MPLAB® XC8 C Compiler User’s Guide
(237) function "*" redefined
(Parser)
More than one definition for a function has been encountered in this module. Function
overloading is illegal, for example:
int twice(int a)
{
return a*2;
}
/* only one prototype & definition of rv can exist */
long twice(long a)
{
return a*2;
}
(238) illegal initialization
(Parser)
You can’t initialize a typedef declaration, because it does not reserve any storage that
can be initialized, for example:
/* oops -- uint is a type, not a variable */
typedef unsigned int uint = 99;
(239) identifier "*" redefined (from line *)
(Parser)
This identifier has already been defined in the same scope. It cannot be defined again,
for example:
int a;
int a;
/* a filescope variable called "a" */
/* attempting to define another of the same name */
Note that variables with the same name, but defined with different scopes are legal, but
not recommended.
(240) too many initializers
(Parser)
There are too many initializers for this object. Check the number of initializers against
the object definition (array or structure), for example:
/* three elements, but four initializers */
int ivals[3] = { 2, 4, 6, 8};
(241) initialization syntax
(Parser)
The initialization of this object is syntactically incorrect. Check for the correct placement
and number of braces and commas, for example:
int iarray[10] = {{’a’, ’b’, ’c’};
/* oops -- one two many {s */
(242) illegal type for switch expression
(Parser)
A switch operation must have an expression that is either an integral type or an enumerated value, e.g:
double d;
switch(d) { /* oops -- this must be integral */
case ’1.0’:
d = 0;
}
DS52053B-page 392
2012 Microchip Technology Inc.
Error and Warning Messages
(243) inappropriate break/continue
(Parser)
A break or continue statement has been found that is not enclosed in an appropriate
control structure. A continue can only be used inside a while, for or do while
loop, while break can only be used inside those loops or a switch statement, for
example:
switch(input) {
case 0:
if(output == 0)
input = 0xff;
} /* oops! this shouldn’t be here and closed the switch */
break;
/* this should be inside the switch */
(244) "default" case redefined
(Parser)
There is only allowed to be one default label in a switch statement. You have more
than one, for example:
switch(a) {
default:
b = 9;
break;
default:
b = 10;
break;
/* if this is the default case... */
/* then what is this? */
(245) "default" case not in switch
(Parser)
A label has been encountered called default but it is not enclosed by a switch statement. A default label is only legal inside the body of a switch statement.
If there is a switch statement before this default label, there may be one too many
closing braces in the switch code which would prematurely terminate the switch
statement. See message 246.
(246) case label not in switch
(Parser)
A case label has been encountered, but there is no enclosing switch statement. A
case label may only appear inside the body of a switch statement.
If there is a switch statement before this case label, there may be one too many closing braces in the switch code which would prematurely terminate the switch
statement, for example:
switch(input) {
case ’0’:
count++;
break;
case ’1’:
if(count>MAX)
count= 0;
}
/* oops -- this shouldn’t be here */
break;
case ’2’:
/* error flagged here */
2012 Microchip Technology Inc.
DS52053B-page 393
MPLAB® XC8 C Compiler User’s Guide
(247) duplicate label "*"
(Parser)
The same name is used for a label more than once in this function. Note that the scope
of labels is the entire function, not just the block that encloses a label, for example:
start:
if(a > 256)
goto end;
start:
if(a == 0)
goto start;
/* error flagged here */
/* which start label do I jump to? */
(248) inappropriate "else"
(Parser)
An else keyword has been encountered that cannot be associated with an if statement. This may mean there is a missing brace or other syntactic error, for example:
/* here is a comment which I have forgotten to close...
if(a > b) {
c = 0;
/* ... that will be closed here, thus removing the "if" */
else
/* my "if" has been lost */
c = 0xff;
(249) probable missing "}" in previous block
(Parser)
The compiler has encountered what looks like a function or other declaration, but the
preceding function has not been ended with a closing brace. This probably means that
a closing brace has been omitted from somewhere in the previous function, although it
may well not be the last one, for example:
void set(char a)
{
PORTA = a;
void clear(void)
{
PORTA = 0;
}
/* the closing brace was left out here */
/* error flagged here */
MESSAGES 250-499
(251) array dimension redeclared
(Parser)
An array dimension has been declared as a different non-zero value from its previous
declaration. It is acceptable to redeclare the size of an array that was previously
declared with a zero dimension, but not otherwise, for example:
extern int array[5];
int array[10];
/* oops -- has it 5 or 10 elements? */
(252) argument * conflicts with prototype
(Parser)
The argument specified (argument 0 is the left most argument) of this function definition
does not agree with a previous prototype for this function, for example:
/* this is supposedly calc’s prototype */
extern int calc(int, int);
int calc(int a, long int b) /* hmmm -- which is right? */
{
/* error flagged here */
return sin(b/a);
}
DS52053B-page 394
2012 Microchip Technology Inc.
Error and Warning Messages
(253) argument list conflicts with prototype
(Parser)
The argument list in a function definition is not the same as a previous prototype for
that function. Check that the number and types of the arguments are all the same.
extern int calc(int);
int calc(int a, int b)
{
return a + b;
}
/* this is supposedly calc’s prototype */
/* hmmm -- which is right? */
/* error flagged here */
(254) undefined *: "*"
(Parser)
This is an internal compiler error. Contact Microchip Technical Support with details.
(255) not a member of the struct/union "*"
(Parser)
This identifier is not a member of the structure or union type with which it used here, for
example:
struct {
int a, b, c;
} data;
if(data.d)
/* oops -there is no member d in this structure */
return;
(256) too much indirection
(Parser)
A pointer declaration may only have 16 levels of indirection.
(257) only "register" storage class allowed
(Parser)
The only storage class allowed for a function parameter is register, for example:
void process(static int input)
(258) duplicate qualifier
(Parser)
There are two occurrences of the same qualifier in this type specification. This can
occur either directly or through the use of a typedef. Remove the redundant qualifier.
For example:
typedef volatile int vint;
/* oops -- this results in two volatile qualifiers */
volatile vint very_vol;
(259) can’t be qualified both far and near
(Parser)
It is illegal to qualify a type as both far and near, for example:
far near int spooky;
/* oops -- choose far or near, not both */
(260) undefined enum tag "*"
(Parser)
This enum tag has not been defined, for example:
enum WHAT what;
/* a definition for WHAT was never seen */
(261) struct/union member "*" redefined
(Parser)
This name of this member of the struct or union has already been used in this struct
or union, for example:
struct {
int a;
int b;
int a;
} input;
2012 Microchip Technology Inc.
/* oops -- a different name is required here */
DS52053B-page 395
MPLAB® XC8 C Compiler User’s Guide
(262) struct/union "*" redefined
(Parser)
A structure or union has been defined more than once, for example:
struct {
int a;
} ms;
struct {
int a;
} ms;
/* was this meant to be the same name as above? */
(263) members can’t be functions
(Parser)
A member of a structure or a union may not be a function. It may be a pointer to a function, for example:
struct {
int a;
int get(int);
} object;
/* should be a pointer: int (*get)(int); */
(264) bad bitfield type
(Parser)
A bit-field may only have a type of int (or unsigned), for example:
struct FREG {
char b0:1;
char
:6;
char b7:1;
} freg;
/* these must be part of an int, not char */
(265) integer constant expected
(Parser)
A colon appearing after a member name in a structure declaration indicates that the
member is a bit-field. An integral constant must appear after the colon to define the
number of bits in the bit-field, for example:
struct {
unsigned first: /* oops -- should be: unsigned first; */
unsigned second;
} my_struct;
If this was meant to be a structure with bit-fields, then the following illustrates an
example:
struct {
unsigned first : 4;
unsigned second: 4;
} my_struct;
/* 4 bits wide */
/* another 4 bits */
(266) storage class illegal
(Parser)
A structure or union member may not be given a storage class. Its storage class is
determined by the storage class of the structure, for example:
struct {
/* no additional qualifiers may be present with members */
static int first;
} ;
DS52053B-page 396
2012 Microchip Technology Inc.
Error and Warning Messages
(267) bad storage class
(Code Generator)
The code generator has encountered a variable definition whose storage class is
invalid, for example:
auto int foo; /* auto not permitted with global variables */
int power(static int a) /* parameters may not be static */
{
return foo * a;
}
(268) inconsistent storage class
(Parser)
A declaration has conflicting storage classes. Only one storage class should appear in
a declaration, for example:
extern static int where;
/* so is it static or extern? */
(269) inconsistent type
(Parser)
Only one basic type may appear in a declaration, for example:
int float if;
/* is it int or float? */
(270) variable can’t have storage class "register"
(Parser)
Only function parameters or auto variables may be declared using the register
qualifier, for example:
register int gi;
/* this cannot be qualified register */
int process(register int input) /* this is okay */
{
return input + gi;
}
(271) type can’t be long
(Parser)
Only int and float can be qualified with long.
long char lc;
/* what? */
(272) type can’t be short
(Parser)
Only int can be modified with short, for example:
short float sf;
/* what? */
(273) type can’t be both signed and unsigned
(Parser)
The type modifiers signed and unsigned cannot be used together in the same declaration, as they have opposite meaning, for example:
signed unsigned int confused;
/* which is it? */
(274) type can’t be unsigned
(Parser)
A floating-point type cannot be made unsigned, for example:
unsigned float uf;
/* what? */
(275) "..." illegal in non-prototype argument list
(Parser)
The ellipsis symbol may only appear as the last item in a prototyped argument list. It
may not appear on its own, nor may it appear after argument names that do not have
types; i.e., K&R-style non-prototype function definitions. For example:
/* K&R-style non-prototyped function definition */
int kandr(a, b, ...)
int a, b;
{
2012 Microchip Technology Inc.
DS52053B-page 397
MPLAB® XC8 C Compiler User’s Guide
(276) type specifier required for prototyped argument
(Parser)
A type specifier is required for a prototyped argument. It is not acceptable to just have
an identifier.
(277) can’t mix prototyped and non-prototyped arguments
(Parser)
A function declaration can only have all prototyped arguments (i.e., with types inside
the parentheses) or all K&R style args (i.e., only names inside the parentheses and the
argument types in a declaration list before the start of the function body), for example:
int plus(int a, b)
int b;
{
return a + b;
}
/* oops -- a is prototyped, b is not */
(278) argument "*" redeclared
(Parser)
The specified argument is declared more than once in the same argument list, for
example:
/* can’t have two parameters called "a" */
int calc(int a, int a)
(279) initialization of function arguments is illegal
(Parser)
A function argument can’t have an initializer in a declaration. The initialization of the
argument happens when the function is called and a value is provided for the argument
by the calling function, for example:
/* oops -- a is initialized when proc is called */
extern int proc(int a = 9);
(280) arrays of functions are illegal
(Parser)
You cannot define an array of functions. You can; however, define an array of pointers
to functions, for example:
int * farray[]();
/* oops -- should be: int (* farray[])(); */
(281) functions can’t return functions
(Parser)
A function cannot return a function. It can return a function pointer. A function returning
a pointer to a function could be declared like this: int (* (name()))(). Note the many
parentheses that are necessary to make the parts of the declaration bind correctly.
(282) functions can’t return arrays
(Parser)
A function can return only a scalar (simple) type or a structure. It cannot return an array.
(283) dimension required
(Parser)
Only the most significant (i.e., the first) dimension in a multi-dimension array may not
be assigned a value. All succeeding dimensions must be present as a constant
expression, for example:
/* This should be, for example: int arr[][7] */
int get_element(int arr[2][])
{
return array[1][6];
}
(284) invalid dimension
(Parser)
This is an internal compiler error. Contact Microchip Technical Support with details.
DS52053B-page 398
2012 Microchip Technology Inc.
Error and Warning Messages
(285) no identifier in declaration
(Parser)
The identifier is missing in this declaration. This error can also occur where the compiler
has been confused by such things as missing closing braces, for example:
void interrupt(void)
{
}
/* what is the name of this function? */
(286) declarator too complex
(Parser)
This declarator is too complex for the compiler to handle. Examine the declaration and
find a way to simplify it. If the compiler finds it too complex, so will anybody maintaining
the code.
(287) arrays of bits or pointers to bit are illegal
(Parser)
It is not legal to have an array of bits, or a pointer to bit variable, for example:
bit barray[10];
bit * bp;
/* wrong -- no bit arrays */
/* wrong -- no pointers to bit variables */
(288) only functions may be void
(Parser)
A variable may not be void. Only a function can be void, for example:
int a;
void b;
/* this makes no sense */
(289) only functions may be qualified "interrupt"
(Parser)
The qualifier interrupt may not be applied to anything except a function, for
example:
/* variables cannot be qualified interrupt */
interrupt int input;
(290) illegal function qualifier(s)
(Parser)
A qualifier has been applied to a function which makes no sense in this context. Some
qualifier only make sense when used with an lvalue, i.e., const or volatile. This
may indicate that you have forgotten a star * that is indicating that the function should
return a pointer to a qualified object, for example:
const char ccrv(void) /* const * char ccrv(void) perhaps? */
{
/* error flagged here */
return ccip;
}
(291) K&R identifier "*" not an argument
(Parser)
This identifier that has appeared in a K&R style argument declarator is not listed inside
the parentheses after the function name, for example:
int process(input)
int unput;
/* oops -- that should be int input; */
{
}
(292) function parameter may not be a function
(Parser)
A function parameter may not be a function. It may be a pointer to a function, so perhaps a "*" has been omitted from the declaration.
(293) bad size in index_type()
(Parser)
This is an internal compiler error. Contact Microchip Technical Support with details.
2012 Microchip Technology Inc.
DS52053B-page 399
MPLAB® XC8 C Compiler User’s Guide
(294) can’t allocate * bytes of memory
(Code Generator, Hexmate)
This is an internal compiler error. Contact Microchip Technical Support with details.
(295) expression too complex
(Parser)
This expression has caused overflow of the compiler’s internal stack and should be
re-arranged or split into two expressions.
(296) out of memory
(Objtohex)
This could be an internal compiler error. Contact Microchip Technical Support with
details.
(297) bad argument (*) to tysize()
(Parser)
This is an internal compiler error. Contact Microchip Technical Support with details.
(298) end of file in #asm
(Preprocessor)
An end of file has been encountered inside a #asm block. This probably means the
#endasm is missing or misspelled, for example:
#asm
MOV
MOV
}
r0, #55
[r1], r0
/* oops -- where is the #endasm */
(300) unexpected end of file
(Parser)
An end-of-file in a C module was encountered unexpectedly, for example:
void main(void)
{
init();
run();
/* is that it? What about the close brace */
(301) end of file on string file
(Parser)
This is an internal compiler error. Contact Microchip Technical Support with details.
(302) can’t reopen "*": *
(Parser)
This is an internal compiler error. Contact Microchip Technical Support with details.
(303) can’t allocate * bytes of memory (line *)
(Parser)
The parser was unable to allocate memory for the longest string encountered, as it
attempts to sort and merge strings. Try reducing the number or length of strings in this
module.
(306) can’t allocate * bytes of memory for *
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(307) too many qualifier names
(Parser)
This is an internal compiler error. Contact Microchip Technical Support with details.
(308) too many case labels in switch
(Code Generator)
There are too many case labels in this switch statement. The maximum allowable
number of case labels in any one switch statement is 511.
(309) too many symbols
(Assembler)
There are too many symbols for the assembler’s symbol table. Reduce the number of
symbols in your program.
DS52053B-page 400
2012 Microchip Technology Inc.
Error and Warning Messages
(310) "]" expected
(Parser)
A closing square bracket was expected in an array declaration or an expression using
an array index, for example:
process(carray[idx);
/* oops -should be: process(carray[idx]); */
(311) closing quote expected
(Parser)
A closing quote was expected for the indicated string.
(312) "*" expected
(Parser)
The indicated token was expected by the parser.
(313) function body expected
(Parser)
Where a function declaration is encountered with K&R style arguments (i.e., argument
names but no types inside the parentheses) a function body is expected to follow, for
example:
/* the function block must follow, not a semicolon */
int get_value(a, b);
(314) ";" expected
(Parser)
A semicolon is missing from a statement. A close brace or keyword was found following
a statement with no terminating semicolon , for example:
while(a) {
b = a-- /* oops -- where is the semicolon? */
}
/* error is flagged here */
Note: Omitting a semicolon from statements not preceding a close brace or keyword
typically results in some other error being issued for the following code which the parser
assumes to be part of the original statement.
(315) "{" expected
(Parser)
An opening brace was expected here. This error may be the result of a function definition missing the opening brace , for example:
/* oops! no opening brace after the prototype */
void process(char c)
return max(c, 10) * 2; /* error flagged here */
}
(316) "}" expected
(Parser)
A closing brace was expected here. This error may be the result of a initialized array
missing the closing brace , for example:
char carray[4] = { 1, 2, 3, 4;
/* oops -- no closing brace */
(317) "(" expected
(Parser)
An opening parenthesis , (, was expected here. This must be the first token after a
while , for , if , do or asm keyword, for example:
if a == b
b = 0;
/* should be: if(a == b) */
(318) string expected
(Parser)
The operand to an asm statement must be a string enclosed in parentheses, for
example:
asm(nop);
2012 Microchip Technology Inc.
/* that should be asm("nop");
DS52053B-page 401
MPLAB® XC8 C Compiler User’s Guide
(319) while expected
(Parser)
The keyword while is expected at the end of a do statement, for example:
do {
func(i++);
}
if(i > 5)
end();
/* do the block while what condition is true? */
/* error flagged here */
(320) ":" expected
(Parser)
A colon is missing after a case label, or after the keyword default. This often occurs
when a semicolon is accidentally typed instead of a colon, for example:
switch(input) {
case 0;
state = NEW;
/* oops -- that should have been: case 0: */
(321) label identifier expected
(Parser)
An identifier denoting a label must appear after goto, for example:
if(a)
goto 20;
/* this is not BASIC -- a valid C label must follow a goto */
(322) enum tag or "{" expected
(Parser)
After the keyword enum must come either an identifier that is or will be defined as an
enum tag, or an opening brace, for example:
enum 1, 2;
/* should be, for example: enum {one=1, two }; */
(323) struct/union tag or "{" expected
(Parser)
An identifier denoting a structure or union or an opening brace must follow a struct
or union keyword, for example:
struct int a;
/* this is not how you define a structure */
You might mean something like:
struct {
int a;
} my_struct;
(324) too many arguments for printf-style format string
(Parser)
There are too many arguments for this format string. This is harmless, but may represent an incorrect format string, for example:
/* oops -- missed a placeholder? */
printf("%d - %d", low, high, median);
(325) error in printf-style format string
(Parser)
There is an error in the format string here. The string has been interpreted as a
printf() style format string, and it is not syntactically correct. If not corrected, this will
cause unexpected behavior at run time, for example:
printf("%l", lll);
/* oops -- maybe: printf("%ld", lll); */
(326) long int argument required in printf-style format string
(Parser)
A long argument is required for this format specifier. Check the number and order of
format specifiers and corresponding arguments, for example:
printf("%lx", 2);
DS52053B-page 402
// maybe you meant: printf("%lx", 2L);
2012 Microchip Technology Inc.
Error and Warning Messages
(327) long long int argument required in printf-style format string
(Parser)
A long long argument is required for this format specifier. Check the number and
order of format specifiers and corresponding arguments, for example:
printf("%llx", 2);
// maybe you meant: printf("%llx", 2LL);
Note that MPLAB XC8 does not provide direct support for a long long integer type.
(328) int argument required in printf-style format string
(Parser)
An integral argument is required for this printf-style format specifier. Check the number
and order of format specifiers and corresponding arguments, for example:
printf("%d", 1.23); /* wrong number or wrong placeholder */
(329) double argument required in printf-style format string
(Parser)
The printf format specifier corresponding to this argument is %f or similar, and requires
a floating-point expression. Check for missing or extra format specifiers or arguments
to printf.
printf("%f", 44);
/* should be: printf("%f", 44.0); */
(330) pointer to * argument required in printf-style format string
(Parser)
A pointer argument is required for this format specifier. Check the number and order of
format specifiers and corresponding arguments.
(331) too few arguments for printf-style format string
(Parser)
There are too few arguments for this format string. This would result in a garbage value
being printed or converted at run time, for example:
printf("%d - %d", low);
/* oops! where is the other value to print? */
(332) "interrupt_level" should be 0 to 7
(Parser)
The pragma interrupt_level must have an argument from 0 to 7; however,
mid-range devices only use level 1; PIC18 devices can use levels 1 or 2. For example:
#pragma interrupt_level 9 /* oops -- the level is too high */
void interrupt isr(void)
{
/* isr code goes here */
}
(333) unrecognized qualifier name after "strings" (Parser)
The pragma strings was passed a qualifier that was not identified, for example:
/* oops -- should that be #pragma strings const ? */
#pragma strings cinst
(334) unrecognized qualifier name after "printf_check"
(Parser)
The #pragma printf_check was passed a qualifier that could not be identified, for
example:
/* oops -- should that be const not cinst? */
#pragma printf_check(printf) cinst
(335) unknown pragma "*"
(Parser)
An unknown pragma directive was encountered, for example:
#pragma rugsused myFunc w
2012 Microchip Technology Inc.
/* I think you meant regsused */
DS52053B-page 403
MPLAB® XC8 C Compiler User’s Guide
(336) string concatenation across lines
(Parser)
Strings on two lines will be concatenated. Check that this is the desired result, for
example:
char * cp = "hi"
"there";
/* this is okay,
but is it what you had intended? */
(337) line does not have a newline on the end
(Parser)
The last line in the file is missing the newline (operating system dependent character)
from the end. Some editors will create such files, which can cause problems for include
files. The ANSI C standard requires all source files to consist of complete lines only.
(338) can’t create * file "*"
(Any)
The application tried to create or open the named file, but it could not be created. Check
that all file path names are correct.
(339) initializer in extern declaration
(Parser)
A declaration containing the keyword extern has an initializer. This overrides the
extern storage class, since to initialise an object it is necessary to define (i.e., allocate
storage for) it, for example:
extern int other = 99;
/* if it’s extern and not allocated
storage, how can it be initialized? */
(340) string not terminated by null character
(Parser)
A char array is being initialized with a string literal larger than the array. Hence there is
insufficient space in the array to safely append a null terminating character, for
example:
char foo[5] = "12345"; /* the string stored in foo won’t have
a null terminating, i.e.
foo = [’1’, ’2’, ’3’, ’4’, ’5’] */
(343) implicit return at end of non-void function
(Parser)
A function which has been declared to return a value has an execution path that will
allow it to reach the end of the function body, thus returning without a value. Either
insert a return statement with a value, or if the function is not to return a value,
declare it void, for example:
int mydiv(double a, int b)
{
if(b != 0)
return a/b;
/* what about when b is 0? */
}
/* warning flagged here */
(344) non-void function returns no value
(Parser)
A function that is declared as returning a value has a return statement that does not
specify a return value, for example:
int get_value(void)
{
if(flag)
return val++;
return;
/* what is the return value in this instance? */
}
DS52053B-page 404
2012 Microchip Technology Inc.
Error and Warning Messages
(345) unreachable code
(Parser)
This section of code will never be executed, because there is no execution path by
which it could be reached, for example:
while(1)
process();
flag = FINISHED;
/* how does this loop finish? */
/* how do we get here? */
(346) declaration of "*" hides outer declaration
(Parser)
An object has been declared that has the same name as an outer declaration (i.e., one
outside and preceding the current function or block). This is legal, but can lead to
accidental use of one variable when the outer one was intended, for example:
int input;
/* input has filescope */
void process(int a)
{
int input;
/* local blockscope input */
a = input;
/* this will use the local variable.
Is this right? */
(347) external declaration inside function
(Parser)
A function contains an extern declaration. This is legal but is invariably not desirable
as it restricts the scope of the function declaration to the function body. This means that
if the compiler encounters another declaration, use or definition of the extern object
later in the same file, it will no longer have the earlier declaration and thus will be unable
to check that the declarations are consistent. This can lead to strange behavior of your
program or signature errors at link time. It will also hide any previous declarations of
the same thing, again subverting the compiler’s type checking. As a general rule,
always declare extern variables and functions outside any other functions. For
example:
int process(int a)
{
/* this would be better outside the function */
extern int away;
return away + a;
}
(348) auto variable "*" should not be qualified
(Parser)
An auto variable should not have qualifiers such as near or far associated with it. Its
storage class is implicitly defined by the stack organization. An auto variable may be
qualified with static , but it is then no longer auto.
(349) non-prototyped function declaration for "*"
(Parser)
A function has been declared using old-style (K&R) arguments. It is preferable to use
prototype declarations for all functions, for example:
int process(input)
int input;
/* warning flagged here */
{
}
This would be better written:
int process(int input)
{
}
2012 Microchip Technology Inc.
DS52053B-page 405
MPLAB® XC8 C Compiler User’s Guide
(350) unused * "*" (from line *)
(Parser)
The indicated object was never used in the function or module being compiled. Either
this object is redundant, or the code that was meant to use it was excluded from compilation or misspelled the name of the object. Note that the symbols rcsid and
sccsid are never reported as being unused.
(352) float parameter coerced to double
(Parser)
Where a non-prototyped function has a parameter declared as float, the compiler
converts this into a double float. This is because the default C type conversion conventions provide that when a floating-point number is passed to a non-prototyped function, it will be converted to double. It is important that the function declaration be
consistent with this convention, for example:
double inc_flt(f)
float f;
{
return f * 2;
}
/* f will be converted to double */
/* warning flagged here */
(353) sizeof external array "*" is zero
(Parser)
The size of an external array evaluates to zero. This is probably due to the array not
having an explicit dimension in the extern declaration.
(354) possible pointer truncation
(Parser)
A pointer qualified far has been assigned to a default pointer or a pointer qualified near,
or a default pointer has been assigned to a pointer qualified near. This may result in
truncation of the pointer and loss of information, depending on the memory model in
use.
(355) implicit signed to unsigned conversion
(Parser)
A signed number is being assigned or otherwise converted to a larger unsigned
type. Under the ANSI C “value preserving” rules, this will result in the signed value
being first sign-extended to a signed number the size of the target type, then converted to unsigned (which involves no change in bit pattern). Thus an unexpected
sign extension can occur. To ensure this does not happen, first convert the signed value
to an unsigned equivalent, for example:
signed char sc;
unsigned int ui;
ui = sc;
/* if sc contains 0xff,
ui will contain 0xffff for example */
will perform a sign extension of the char variable to the longer type. If you do not want
this to take place, use a cast, for example:
ui = (unsigned char)sc;
(356) implicit conversion of float to integer
(Parser)
A floating-point value has been assigned or otherwise converted to an integral type.
This could result in truncation of the floating-point value. A typecast will make this warning go away.
double dd;
int i;
i = dd;
/* is this really what you meant? */
If you do intend to use an expression like this, then indicate that this is so by a cast:
i = (int)dd;
DS52053B-page 406
2012 Microchip Technology Inc.
Error and Warning Messages
(357) illegal conversion of integer to pointer
(Parser)
An integer has been assigned to or otherwise converted to a pointer type. This will usually mean you have used the wrong variable, but if this is genuinely what you want to
do, use a typecast to inform the compiler that you want the conversion and the warning
will be suppressed. This may also mean you have forgotten the & address operator, for
example:
int * ip;
int i;
ip = i;
/* oops -- did you mean ip = &i ? */
If you do intend to use an expression like this, then indicate that this is so by a cast:
ip = (int *)i;
(358) illegal conversion of pointer to integer
(Parser)
A pointer has been assigned to or otherwise converted to a integral type. This will usually mean you have used the wrong variable, but if this is genuinely what you want to
do, use a typecast to inform the compiler that you want the conversion and the warning
will be suppressed. This may also mean you have forgotten the * dereference operator,
for example:
int * ip;
int i;
i = ip;
/* oops -- did you mean i = *ip ? */
If you do intend to use an expression like this, indicate your intention by a cast:
i = (int)ip;
(359) illegal conversion between pointer types
(Parser)
A pointer of one type (i.e., pointing to a particular kind of object) has been converted
into a pointer of a different type. This will usually mean you have used the wrong variable, but if this is genuinely what you want to do, use a typecast to inform the compiler
that you want the conversion and the warning will be suppressed, for example:
long input;
char * cp;
cp = &input;
/* is this correct? */
This is common way of accessing bytes within a multi-byte variable. To indicate that this
is the intended operation of the program, use a cast:
cp = (char *)&input;
/* that’s better */
This warning may also occur when converting between pointers to objects which have
the same type, but which have different qualifiers, for example:
char * cp;
/* yes, but what sort of characters? */
cp = "I am a string of characters";
If the default type for string literals is const char * , then this warning is quite valid.
This should be written:
const char * cp;
cp = "I am a string of characters";
/* that’s better */
Omitting a qualifier from a pointer type is often disastrous, but almost certainly not what
you intend.
2012 Microchip Technology Inc.
DS52053B-page 407
MPLAB® XC8 C Compiler User’s Guide
(360) array index out of bounds
(Parser)
An array is being indexed with a constant value that is less than zero, or greater than
or equal to the number of elements in the array. This warning will not be issued when
accessing an array element via a pointer variable, for example:
int i, * ip, input[10];
i = input[-2];
ip = &input[5];
i = ip[-2];
/* oops -- this element doesn’t exist */
/* this is okay */
(361) function declared implicit int
(Parser)
Where the compiler encounters a function call of a function whose name is presently
undefined, the compiler will automatically declare the function to be of type int , with
unspecified (K&R style) parameters. If a definition of the function is subsequently
encountered, it is possible that its type and arguments will be different from the earlier
implicit declaration, causing a compiler error. The solution is to ensure that all functions
are defined or at least declared before use, preferably with prototyped parameters. If it
is necessary to make a forward declaration of a function, it should be preceded with the
keywords extern or static as appropriate. For example:
/* I may prevent an error arising from calls below */
void set(long a, int b);
void main(void)
{
/* by here a prototype for set should have seen */
set(10L, 6);
}
(362) redundant "&" applied to array
(Parser)
The address operator & has been applied to an array. Since using the name of an array
gives its address anyway, this is unnecessary and has been ignored, for example:
int array[5];
int * ip;
/* array is a constant, not a variable; the & is redundant. */
ip = &array;
(363) redundant "&" or "*" applied to function address
(Parser)
The address operator “&” has been applied to a function. Since using the name of a
function gives its address anyway, this is unnecessary and has been ignored, for
example:
extern void foo(void);
void main(void)
{
void(*bar)(void);
/* both assignments are equivalent */
bar = &foo;
bar = foo; /* the & is redundant */
}
(364) attempt to modify object qualified *
(Parser)
Objects declared const or code may not be assigned to or modified in any other way
by your program. The effect of attempting to modify such an object is compiler specific.
const int out = 1234;
out = 0;
DS52053B-page 408
/* "out" is read only */
/* oops -writing to a read-only object */
2012 Microchip Technology Inc.
Error and Warning Messages
(365) pointer to non-static object returned
(Parser)
This function returns a pointer to a non-static (e.g., auto) variable. This is likely to
be an error, since the storage associated with automatic variables becomes invalid
when the function returns, for example:
char * get_addr(void)
{
char c;
/* returning this is dangerous;
the pointer could be dereferenced */
return &c;
}
(366) operands of "*" not same pointer type
(Parser)
The operands of this operator are of different pointer types. This probably means you
have used the wrong pointer, but if the code is actually what you intended, use a
typecast to suppress the error message.
(367) identifier is already extern; can’t be static
(Parser)
This function was already declared extern, possibly through an implicit declaration. It
has now been redeclared static, but this redeclaration is invalid.
void main(void)
{
/* at this point the compiler assumes set is extern... */
set(10L, 6);
}
/* now it finds out otherwise */
static void set(long a, int b)
{
PORTA = a + b;
}
(368) array dimension on "*[]" ignored
(Preprocessor)
An array dimension on a function parameter has been ignored because the argument
is actually converted to a pointer when passed. Thus arrays of any size may be passed.
Either remove the dimension from the parameter, or define the parameter using pointer
syntax, for example:
/* param should be: "int array[]" or "int *" */
int get_first(int array[10])
{
/* warning flagged here */
return array[0];
}
(369) signed bitfields not supported
(Parser)
Only unsigned bit-fields are supported. If a bit-field is declared to be type int, the
compiler still treats it as unsigned, for example:
struct {
signed int sign: 1;
signed int value: 7;
} ;
/* oops -- this must be unsigned */
(370) illegal basic type; int assumed
(Parser)
The basic type of a cast to a qualified basic type couldn’t not be recognized and the
basic type was assumed to be int, for example:
/* here ling is assumed to be int */
unsigned char bar = (unsigned ling) ’a’;
2012 Microchip Technology Inc.
DS52053B-page 409
MPLAB® XC8 C Compiler User’s Guide
(371) missing basic type; int assumed
(Parser)
This declaration does not include a basic type, so int has been assumed. This declaration is not illegal, but it is preferable to include a basic type to make it clear what is
intended, for example:
char c;
i;
/* don’t let the compiler make assumptions, use : int i */
func(); /* ditto, use: extern int func(int); */
(372) "," expected
(Parser)
A comma was expected here. This could mean you have left out the comma between
two identifiers in a declaration list. It may also mean that the immediately preceding
type name is misspelled, and has thus been interpreted as an identifier, for example:
unsigned char a;
/* thinks: chat & b are unsigned, but where is the comma? */
unsigned chat b;
(373) implicit signed to unsigned conversion
(Parser)
An unsigned type was expected where a signed type was given and was implicitly
cast to unsigned, for example:
unsigned int foo = -1;
/* the above initialization is implicitly treated as:
unsigned int foo = (unsigned) -1; */
(374) missing basic type; int assumed
(Parser)
The basic type of a cast to a qualified basic type was missing and assumed to be int.,
for example:
int i = (signed) 2; /* (signed) assumed to be (signed int) */
(375) unknown FNREC type "*"
(Linker)
This is an internal compiler error. Contact Microchip Technical Support with details.
(376) bad non-zero node in call graph
(Linker)
The linker has encountered a top level node in the call graph that is referenced from
lower down in the call graph. This probably means the program has indirect recursion,
which is not allowed when using a compiled stack.
(378) can’t create * file "*"
(Hexmate)
This type of file could not be created. Is the file or a file by this name already in use?
(379) bad record type "*"
(Linker)
This is an internal compiler error. Ensure the object file is a valid object file. Contact
Microchip Technical Support with details.
(380) unknown record type (*)
(Linker)
This is an internal compiler error. Contact Microchip Technical Support with details.
(381) record "*" too long (*)
(Linker)
This is an internal compiler error. Contact Microchip Technical Support with details.
(382) incomplete record: type = *, length = *
(Dump, Xstrip)
This message is produced by the DUMP or XSTRIP utilities and indicates that the
object file is not a valid object file, or that it has been truncated. Contact Microchip
Technical Support with details.
DS52053B-page 410
2012 Microchip Technology Inc.
Error and Warning Messages
(383) text record has length (*) too small
(Linker)
This is an internal compiler error. Contact Microchip Technical Support with details.
(384) assertion failed: file *, line *, expression *
(Linker, Parser)
This is an internal compiler error. Contact Microchip Technical Support with details.
(387) illegal or too many -G options
(Linker)
There has been more than one linker -g option, or the -g option did not have any
arguments following. The arguments specify how the segment addresses are
calculated.
(388) duplicate -M option
(Linker)
The map file name has been specified to the linker for a second time. This should not
occur if you are using a compiler driver. If invoking the linker manually, ensure that only
one instance of this option is present on the command line. See Section 4.8.8 “-M:
Generate Map File” for information on the correct syntax for this option.
(389) illegal or too many -O options
(Linker)
This linker -o flag is illegal, or another -o option has been encountered. A -o option
to the linker must be immediately followed by a filename with no intervening space.
(390) missing argument to -P
(Linker)
There have been too many -p options passed to the linker, or a -p option was not followed by any arguments. The arguments of separate -p options may be combined and
separated by commas.
(391) missing argument to -Q
(Linker)
The -Q linker option requires the machine type for an argument.
(392) missing argument to -U
(Linker)
The -U (undefine) option needs an argument.
(393) missing argument to -W
(Linker)
The -W option (listing width) needs a numeric argument.
(394) duplicate -D or -H option
(Linker)
The symbol file name has been specified to the linker for a second time. This should
not occur if you are using a compiler driver. If invoking the linker manually, ensure that
only one instance of either of these options is present on the command line.
(395) missing argument to -J
(Linker)
The maximum number of errors before aborting must be specified following the -j
linker option.
(397) usage: hlink [-options] files.obj files.lib
(Linker)
Improper usage of the command-line linker. If you are invoking the linker directly, refer
to Section Section 7.2 “Operation” for more details. Otherwise this may be an internal
compiler error and you should contact Microchip Technical Support with details.
(398) output file can’t be also an input file
(Linker)
The linker has detected an attempt to write its output file over one of its input files. This
cannot be done, because it needs to simultaneously read and write input and output
files.
2012 Microchip Technology Inc.
DS52053B-page 411
MPLAB® XC8 C Compiler User’s Guide
(400) bad object code format
(Linker)
This is an internal compiler error. The object code format of an object file is invalid.
Ensure it is a valid object file. Contact Microchip Technical Support with details.
(402) bad argument to -F
(Objtohex)
The -F option for objtohex has been supplied an invalid argument. If you are invoking this command-line tool directly, refer to Section 8.3 “OBJTOHEX” for more details.
Otherwise this may be an internal compiler error and you should contact Microchip
Technical Support with details.
(403) bad -E option: "*"
(Objtohex)
This is an internal compiler error. Contact Microchip Technical Support with details.
(404) bad maximum length value to -
(Objtohex)
The first value to the OBJTOHEX -n,m HEX length/rounding option is invalid.
(405) bad record size rounding value to -
(Objtohex)
The second value to the OBJTOHEX -n,m HEX length/rounding option is invalid.
(406) bad argument to -A
(Objtohex)
This is an internal compiler error. Contact Microchip Technical Support with details.
(407) bad argument to -U
(Objtohex)
This is an internal compiler error. Contact Microchip Technical Support with details.
(408) bad argument to -B
(Objtohex)
This option requires an integer argument in either base 8, 10 or 16. If you are invoking
objtohex directly then see Section 8.3 “OBJTOHEX” for more details. Otherwise
this may be an internal compiler error and you should contact Microchip Technical
Support with details.
(409) bad argument to -P
(Objtohex)
This option requires an integer argument in either base 8, 10 or 16. If you are invoking
objtohex directly, see Section 8.3 “OBJTOHEX” for more details. This could be an
internal compiler error and you should contact Microchip Technical Support with details.
(410) bad combination of options
(Objtohex)
The combination of options supplied to OBJTOHEX is invalid.
(412) text does not start at 0
(Objtohex)
Code in some things must start at zero. Here it doesn’t.
(413) write error on "*"
(Assembler, Linker, Cromwell)
A write error occurred on the named file. This probably means you have run out of disk
space.
(414) read error on "*"
(Linker)
The linker encountered an error trying to read this file.
(415) text offset too low in COFF file
(Objtohex)
This is an internal compiler error. Contact Microchip Technical Support with details.
(416) bad character (*) in extended TEKHEX line
(Objtohex)
This is an internal compiler error. Contact Microchip Technical Support with details.
DS52053B-page 412
2012 Microchip Technology Inc.
Error and Warning Messages
(417) seek error in "*"
(Linker)
This is an internal compiler error. Contact Microchip Technical Support with details.
(418) image too big
(Objtohex)
This is an internal compiler error. Contact Microchip Technical Support with details.
(419) object file is not absolute
(Objtohex)
The object file passed to OBJTOHEX has relocation items in it. This may indicate it is
the wrong object file, or that the linker or OBJTOHEX have been given invalid options.
The object output files from the assembler are relocatable, not absolute. The object file
output of the linker is absolute.
(420) too many relocation items
(Objtohex)
This is an internal compiler error. Contact Microchip Technical Support with details.
(421) too many segments
(Objtohex)
This is an internal compiler error. Contact Microchip Technical Support with details.
(422) no end record
(Linker)
This object file has no end record. This probably means it is not an object file. Contact
Microchip Technical Support if the object file was generated by the compiler.
(423) illegal record type
(Linker)
There is an error in an object file. This is either an invalid object file, or an internal error
in the linker. Contact Microchip Technical Support with details if the object file was created by the compiler.
(424) record too long
(Objtohex)
This is an internal compiler error. Contact Microchip Technical Support with details.
(425) incomplete record
(Objtohex, Libr)
The object file passed to OBJTOHEX or the librarian is corrupted. Contact Microchip
Technical Support with details.
(427) syntax error in checksum list
(Objtohex)
There is a syntax error in a checksum list read by OBJTOHEX. The checksum list is
read from standard input in response to an option.
(428) too many segment fixups
(Objtohex)
This is an internal compiler error. Contact Microchip Technical Support with details.
(429) bad segment fixups
(Objtohex)
This is an internal compiler error. Contact Microchip Technical Support with details.
(430) bad checksum specification
(Objtohex)
A checksum list supplied to OBJTOHEX is syntactically incorrect.
(431) bad argument to -E
(Objtoexe)
This option requires an integer argument in either base 8, 10 or 16. If you are invoking
objtoexe directly then check this argument. Otherwise this may be an internal compiler error and you should contact Microchip Technical Support with details.
2012 Microchip Technology Inc.
DS52053B-page 413
MPLAB® XC8 C Compiler User’s Guide
(432) usage: objtohex [-ssymfile] [object-file [exe-file]]
(Objtohex)
Improper usage of the command-line tool objtohex. If you are invoking objtohex
directly, refer to Section 8.3 “OBJTOHEX” for more details. Otherwise this may be an
internal compiler error and you should contact Microchip Technical Support with details.
(434) too many symbols (*)
(Linker)
There are too many symbols in the symbol table, which has a limit of * symbols.
Change some global symbols to local symbols to reduce the number of symbols.
(435) bad segment selector "*"
(Linker)
The segment specification option (-G) to the linker is invalid, for example:
-GA/f0+10
Did you forget the radix?
-GA/f0h+10
(436) psect "*" re-orged
(Linker)
This psect has had its start address specified more than once.
(437) missing "=" in class spec
(Linker)
A class spec needs an = sign, e.g., -Ctext=ROM. See Section 7.2.3 “-Cpsect=class”
for more information.
(438) bad size in -S option
(Linker)
The address given in a -S specification is invalid: it should be a valid number, in decimal, octal or hexadecimal radix. The radix is specified by a trailing O, for octal, or H for
HEX. A leading 0x may also be used for hexadecimal. Case in not important for any
number or radix. Decimal is the default, for example:
-SCODE=f000
Did you forget the radix?
-SCODE=f000h
(439) bad -D spec: "*"
(Linker)
The format of a -D specification, giving a delta value to a class, is invalid, for example:
-DCODE
What is the delta value for this class? Maybe you meant something like:
-DCODE=2
(440) bad delta value in -D spec
(Linker)
The delta value supplied to a -D specification is invalid. This value should an integer of
base 8, 10 or 16.
(441) bad -A spec: "*"
(Linker)
The format of a -A specification, giving address ranges to the linker, is invalid, for
example:
-ACODE
What is the range for this class? Maybe you meant:
-ACODE=0h-1fffh
DS52053B-page 414
2012 Microchip Technology Inc.
Error and Warning Messages
(442) missing address in -A spec
(Linker)
The format of a -A specification, giving address ranges to the linker, is invalid, for
example:
-ACODE=
What is the range for this class? Maybe you meant:
-ACODE=0h-1fffh
(443) bad low address "*" in -A spec
(Linker)
The low address given in a -A specification is invalid: it should be a valid number, in
decimal, octal or hexadecimal radix. The radix is specified by a trailing O (for octal) or
H for HEX. A leading 0x may also be used for hexadecimal. Case in not important for
any number or radix. Decimal is default, for example:
-ACODE=1fff-3fffh
Did you forget the radix?
-ACODE=1fffh-3fffh
(444) expected "-" in -A spec
(Linker)
There should be a minus sign, -, between the high and low addresses in a -A linker
option, for example:
-AROM=1000h
maybe you meant:
-AROM=1000h-1fffh
(445) bad high address "*" in -A spec
(Linker)
The high address given in a -A specification is invalid: it should be a valid number, in
decimal, octal or hexadecimal radix. The radix is specified by a trailing O, for octal, or H
for HEX. A leading 0x may also be used for hexadecimal. Case in not important for any
number or radix. Decimal is the default, for example:
-ACODE=0h-ffff
Did you forget the radix?
-ACODE=0h-ffffh
See Section 7.2.1 “-Aclass =low-high,...” for more information.
(446) bad overrun address "*" in -A spec
(Linker)
The overrun address given in a -A specification is invalid: it should be a valid number,
in decimal, octal or hexadecimal radix. The radix is specified by a trailing O (for octal)
or H for HEX. A leading 0x may also be used for hexadecimal. Case in not important
for any number or radix. Decimal is default, for example:
-AENTRY=0-0FFh-1FF
Did you forget the radix?
-AENTRY=0-0FFh-1FFh
2012 Microchip Technology Inc.
DS52053B-page 415
MPLAB® XC8 C Compiler User’s Guide
(447) bad load address "*" in -A spec
(Linker)
The load address given in a -A specification is invalid: it should be a valid number, in
decimal, octal or hexadecimal radix. The radix is specified by a trailing O (for octal) or
H for HEX. A leading 0x may also be used for hexadecimal. Case in not important for
any number or radix. Decimal is default, for example:
-ACODE=0h-3fffh/a000
Did you forget the radix?
-ACODE=0h-3fffh/a000h
(448) bad repeat count "*" in -A spec
(Linker)
The repeat count given in a -A specification is invalid, for example:
-AENTRY=0-0FFhxf
Did you forget the radix?
-AENTRY=0-0FFhxfh
(449) syntax error in -A spec: *
(Linker)
The -A spec is invalid. A valid -A spec should be something like:
-AROM=1000h-1FFFh
(450) psect "*" was never defined
(Linker)
This psect has been listed in a -P option, but is not defined in any module within the
program.
(451) bad psect origin format in -P option
(Linker)
The origin format in a -p option is not a validly formed decimal, octal or HEX number,
nor is it the name of an existing psect. A HEX number must have a trailing H, for example:
-pbss=f000
Did you forget the radix?
-pbss=f000h
(452) bad "+" (minimum address) format in -P option
(Linker)
The minimum address specification in the linker’s -p option is badly formatted, for
example:
-pbss=data+f000
Did you forget the radix?
-pbss=data+f000h
(453) missing number after "%" in -P option
(Linker)
The % operator in a -p option (for rounding boundaries) must have a number after it.
DS52053B-page 416
2012 Microchip Technology Inc.
Error and Warning Messages
(454) link and load address can’t both be set to "." in -P option
(Linker)
The link and load address of a psect have both been specified with a dot character.
Only one of these addresses may be specified in this manner, for example:
-Pmypsect=1000h/.
-Pmypsect=./1000h
Both of these options are valid and equivalent. However, the following usage is
ambiguous:
-Pmypsect=./.
What is the link or load address of this psect?
(455) psect "*" not relocated on 0x* byte boundary
(Linker)
This psect is not relocated on the required boundary. Check the relocatability of the
psect and correct the -p option. if necessary.
(456) psect "*" not loaded on 0x* boundary
(Linker)
This psect has a relocatability requirement that is not met by the load address given in
a -p option. For example, if a psect must be on a 4K byte boundary, you could not start
it at 100H.
(459) remove failed, error: *, *
(xstrip)
The creation of the output file failed when removing an intermediate file.
(460) rename failed, error: *, *
(xstrip)
The creation of the output file failed when renaming an intermediate file.
(461) can’t create * file "*"
(Assembler, Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(464) missing key in avmap file
(Linker)
This is an internal compiler error. Contact Microchip Technical Support with details.
(465) undefined symbol "*" in FNBREAK record
(Linker)
The linker has found an undefined symbol in the FNBREAK record for a non-reentrant
function. Contact Microchip Technical Support if this is not handwritten assembler
code.
(466) undefined symbol "*" in FNINDIR record
(Linker)
The linker has found an undefined symbol in the FNINDIR record for a non-reentrant
function. Contact Microchip Technical Support if this is not handwritten assembler
code.
(467) undefined symbol "*" in FNADDR record
(Linker)
The linker has found an undefined symbol in the FNADDR record for a non-reentrant
function. Contact Microchip Technical Support if this is not handwritten assembler
code.
(468) undefined symbol "*" in FNCALL record
(Linker)
The linker has found an undefined symbol in the FNCALL record for a non-reentrant
function. Contact Microchip Technical Support if this is not handwritten assembler
code.
2012 Microchip Technology Inc.
DS52053B-page 417
MPLAB® XC8 C Compiler User’s Guide
(469) undefined symbol "*" in FNROOT record
(Linker)
The linker has found an undefined symbol in the FNROOT record for a non-reentrant
function. Contact Microchip Technical Support if this is not handwritten assembler
code.
(470) undefined symbol "*" in FNSIZE record
(Linker)
The linker has found an undefined symbol in the FNSIZE record for a non-reentrant
function. Contact Microchip Technical Support if this is not handwritten assembler
code.
(471) recursive function calls:
(Linker)
These functions (or function) call each other recursively. One or more of these functions
has statically allocated local variables (compiled stack). Either use the reentrant
keyword (if supported with this compiler) or recode to avoid recursion, for example:
int test(int a)
{
if(a == 5) {
/* recursion may not be supported by some compilers */
return test(a++);
}
return 0;
}
(472) non-reentrant function "*" appears in multiple call graphs: rooted at "*" and "*"
(Linker)
This function can be called from both main-line code and interrupt code. Use the
reentrant keyword, if this compiler supports it, or recode to avoid using local variables or parameters, or duplicate the function, for example:
void interrupt my_isr(void)
{
scan(6);
/* scan is called from an interrupt function */
}
void process(int a)
{
scan(a);
/* scan is also called from main-line code */
}
(473) function "*" is not called from specified interrupt_level
(Linker)
The indicated function is never called from an interrupt function of the same interrupt
level, for example:
#pragma interrupt_level 1
void foo(void)
{
...
}
#pragma interrupt_level 1
void interrupt bar(void)
{
// this function never calls foo()
}
DS52053B-page 418
2012 Microchip Technology Inc.
Error and Warning Messages
(474) no psect specified for function variable/argument allocation
(Linker)
The FNCONF assembler directive which specifies to the linker information regarding the
auto/parameter block was never seen. This is supplied in the standard runtime files if
necessary. This error may imply that the correct run-time startup module was not
linked. Ensure you have used the FNCONF directive if the runtime startup module is
hand-written.
(475) conflicting FNCONF records
(Linker)
The linker has seen two conflicting FNCONF directives. This directive should be specified only once, and is included in the standard runtime startup code which is normally
linked into every program.
(476) fixup overflow referencing * * (location 0x* (0x*+*), size *, value 0x*)
(Linker)
The linker was asked to relocate (fixup) an item that would not fit back into the space
after relocation. See the following error message (477) for more information.
(477) fixup overflow in expression (location 0x* (0x*+*), size *, value 0x*)
(Linker)
Fixup is the process conducted by the linker of replacing symbolic references to variables etc, in an assembler instruction with an absolute value. This takes place after
positioning the psects (program sections or blocks) into the available memory on the
target device. Fixup overflow is when the value determined for a symbol is too large to
fit within the allocated space within the assembler instruction. For example, if an
assembler instruction has an 8-bit field to hold an address and the linker determines
that the symbol that has been used to represent this address has the value 0x110, then
clearly this value cannot be inserted into the instruction.
The causes for this can be many, but hand-written assembler code is always the first
suspect. Badly written C code can also generate assembler that ultimately generates
fixup overflow errors. Consider the following error message.
main.obj: 8: Fixup overflow in expression (loc 0x1FD (0x1FC+1),
size 1, value 0x7FC)
This indicates that the file causing the problem was main.obj. This would be typically
be the output of compiling main.c or main.as. This tells you the file in which you
should be looking. The next number (8 in this example) is the record number in the
object file that was causing the problem. If you use the DUMP utility to examine the
object file, you can identify the record; however, you do not normally need to do this.
The location (loc) of the instruction (0x1FD), the size (in bytes) of the field in the
instruction for the value (1), and the value which is the actual value the symbol represents, is typically the only information needed to track down the cause of this error.
Note that a size which is not a multiple of 8 bits will be rounded up to the nearest byte
size, i.e., a 7 bit space in an instruction will be shown as 1 byte.
Generate an assembler list file for the appropriate module. Look for the address
specified in the error message.
7
8
9
07FC
07FD
07FE
0E21
6FFC
0012
MOVLW 33
MOVWF _foo
RETURN
and to confirm, look for the symbol referenced in the assembler instruction at this
address in the symbol table at the bottom of the same file.
Symbol Table
_foo 01FC
_main 07FF
Fri Aug 12 13:17:37 2004
In this example, the instruction causing the problem takes an 8-bit offset into a bank of
memory, but clearly the address 0x1FC exceeds this size. Maybe the instruction should
have been written as:
2012 Microchip Technology Inc.
DS52053B-page 419
MPLAB® XC8 C Compiler User’s Guide
MOVWF (_foo&0ffh)
which masks out the top bits of the address containing the bank information.
If the assembler instruction that caused this error was generated by the compiler, in the
assembler list file look back up the file from the instruction at fault to determine which
C statement has generated this instruction. You will then need to examine the C code
for possible errors. incorrectly qualified pointers are an common trigger.
(478) * range check failed (location 0x* (0x*+*), value 0x* > limit 0x*)
(Linker)
This is an internal compiler error. Contact Microchip Technical Support with details.
(479) circular indirect definition of symbol "*"
(Linker)
The specified symbol has been equated to an external symbol which, in turn, has been
equated to the first symbol.
(480) function signatures do not match: * (*): 0x*/0x*
(Linker)
The specified function has different signatures in different modules. This means it has
been declared differently; i.e., it may have been prototyped in one module and not
another. Check what declarations for the function are visible in the two modules
specified and make sure they are compatible, for example:
extern int get_value(int in);
/* and in another module: */
/* this is different to the declaration */
int get_value(int in, char type)
{
(481) common symbol "*" psect conflict
(Linker)
A common symbol has been defined to be in more than one psect.
(482) symbol "*" is defined more than once in "*"
(Assembler)
This symbol has been defined in more than one place. The assembler will issue this
error if a symbol is defined more than once in the same module, for example:
_next:
MOVE r0, #55
MOVE [r1], r0
_next:
; oops -- choose a different name
The linker will issue this warning if the symbol (C or assembler) was defined multiple
times in different modules. The names of the modules are given in the error message.
Note that C identifiers often have an underscore prepended to their name after
compilation.
(483) symbol "*" can’t be global
(Linker)
This is an internal compiler error. Contact Microchip Technical Support with details.
(484) psect "*" can’t be in classes "*" and "*"
(Linker)
A psect cannot be in more than one class. This is either due to assembler modules with
conflicting class= options to the PSECT directive, or use of the -C option to the linker,
for example:
psect final,class=CODE
finish:
/* elsewhere: */
psect final,class=ENTRY
DS52053B-page 420
2012 Microchip Technology Inc.
Error and Warning Messages
(485) unknown "with" psect referenced by psect "*"
(Linker)
The specified psect has been placed with a psect using the psect with flag. The psect
it has been placed with does not exist, for example:
psect starttext,class=CODE,with=rext
; was that meant to be with text?
(486) psect "*" selector value redefined
(Linker)
The selector value for this psect has been defined more than once.
(487) psect "*" type redefined: */*
(Linker)
This psect has had its type defined differently by different modules. This probably
means you are trying to link incompatible object modules, i.e., linking 386 flat model
code with 8086 real mode code.
(488) psect "*" memory space redefined: */*
(Linker)
A global psect has been defined in two different memory spaces. Either rename one of
the psects or, if they are the same psect, place them in the same memory space using
the space psect flag, for example:
psect spdata,class=RAM,space=0
ds 6
; elsewhere:
psect spdata,class=RAM,space=1
(489) psect "*" memory delta redefined: */*
(Linker)
A global psect has been defined with two different delta values, for example:
psect final,class=CODE,delta=2
finish:
; elsewhere:
psect final,class=CODE,delta=1
(490) class "*" memory space redefined: */*
(Linker)
A class has been defined in two different memory spaces. Either rename one of the
classes or, if they are the same class, place them in the same memory space.
(491) can’t find 0x* words for psect "*" in segment "*"
(Linker)
One of the main tasks the linker performs is positioning the blocks (or psects) of code
and data that is generated from the program into the memory available for the target
device. This error indicates that the linker was unable to find an area of free memory
large enough to accommodate one of the psects. The error message indicates the
name of the psect that the linker was attempting to position and the segment name
which is typically the name of a class which is defined with a linker -A option.
Section 5.15.2 “Compiler-Generated Psects” lists each compiler-generated psect
and what it contains. Typically psect names which are, or include, text relate to program code. Names such as bss or data refer to variable blocks. This error can be due
to two reasons.
First, the size of the program or the program’s data has exceeded the total amount of
space on the selected device. In other words, some part of your device’s memory has
completely filled. If this is the case, then the size of the specified psect must be
reduced.
2012 Microchip Technology Inc.
DS52053B-page 421
MPLAB® XC8 C Compiler User’s Guide
The second cause of this message is when the total amount of memory needed by the
psect being positioned is sufficient, but that this memory is fragmented in such a way
that the largest contiguous block is too small to accommodate the psect. The linker is
unable to split psects in this situation. That is, the linker cannot place part of a psect at
one location and part somewhere else. Thus, the linker must be able to find a contiguous block of memory large enough for every psect. If this is the cause of the error, then
the psect must be split into smaller psects if possible.
To find out what memory is still available, generate and look in the map file, see
Section 4.8.8 “-M: Generate Map File” for information on how to generate a map file.
Search for the string UNUSED ADDRESS RANGES. Under this heading, look for the
name of the segment specified in the error message. If the name is not present, then
all the memory available for this psect has been allocated. If it is present, there will be
one address range specified under this segment for each free block of memory. Determine the size of each block and compare this with the number of words specified in the
error message.
Psects containing code can be reduced by using all the compiler’s optimizations, or
restructuring the program. If a code psect must be split into two or more small psects,
this requires splitting a function into two or more smaller functions (which may call each
other). These functions may need to be placed in new modules.
Psects containing data may be reduced when invoking the compiler optimizations, but
the effect is less dramatic. The program may need to be rewritten so that it needs less
variables. If the default linker options must be changed, this can be done indirectly
through the driver using the driver -L- option, see Section 4.8.7 “-L-: Adjust Linker
Options Directly”. Section 4.8.8 “-M: Generate Map File” has information on interpreting the map file’s call graph if the compiler you are using uses a compiled stack. (If
the string Call graph: is not present in the map file, then the compiled code uses a
hardware stack.) If a data psect needs to be split into smaller psects, the definitions for
variables will need to be moved to new modules or more evenly spread in the existing
modules. Memory allocation for auto variables is entirely handled by the compiler.
Other than reducing the number of these variables used, the programmer has little control over their operation. This applies whether the compiled code uses a hardware or
compiled stack.
For example, after receiving the message:
Can’t find 0x34 words (0x34 withtotal) for psect text
in segment CODE (error)
look in the map file for the ranges of unused memory.
UNUSED ADDRESS RANGES
CODE
RAM
00000244-0000025F
00001000-0000102f
00300014-00301FFB
In the CODE segment, there is 0x1c (0x25f-0x244+1) bytes of space available in one
block and 0x30 available in another block. Neither of these are large enough to accommodate the psect text which is 0x34 bytes long. Notice, however, that the total amount
of memory available is larger than 0x34 bytes.
(492) attempt to position absolute psect "*" is illegal
(Linker)
This psect is absolute and should not have an address specified in a -P option. Either
remove the abs psect flag, or remove the -P linker option.
(493) origin of psect "*" is defined more than once
(Linker)
The origin of this psect is defined more than once. There is most likely more than one
-p linker option specifying this psect.
DS52053B-page 422
2012 Microchip Technology Inc.
Error and Warning Messages
(494) bad -P format "*/*"
(Linker)
The -P option given to the linker is malformed. This option specifies placement of a
psect, for example:
-Ptext=10g0h
Maybe you meant:
-Ptext=10f0h
(495) use of both "with=" and "INCLASS/INCLASS" allocation is illegal
(Linker)
It is not legal to specify both the link and location of a psect as within a class, when that
psect was also defined using a with psect flag.
(497) psect "*" exceeds max size: *h > *h
(Linker)
The psect has more bytes in it than the maximum allowed as specified using the size
psect flag.
(498) psect "*" exceeds address limit: *h > *h
(Linker)
The maximum address of the psect exceeds the limit placed on it using the limit
psect flag. Either the psect needs to be linked at a different location or there is too much
code/data in the psect.
(499) undefined symbol:
(Assembler, Linker)
The symbol following is undefined at link time. This could be due to spelling error, or
failure to link an appropriate module.
MESSAGES 500-749
(500) undefined symbols:
(Linker)
A list of symbols follows that were undefined at link time. These errors could be due to
spelling error, or failure to link an appropriate module.
(501) program entry point is defined more than once
(Linker)
There is more than one entry point defined in the object files given the linker. End entry
point is specified after the END directive. The runtime startup code defines the entry
point, for example:
powerup:
goto start
END powerup ; end of file and define entry point
; other files that use END should not define another entry point
(502) incomplete * record body: length = *
(Linker)
An object file contained a record with an illegal size. This probably means the file is
truncated or not an object file. Contact Microchip Technical Support with details.
(503) ident records do not match
(Linker)
The object files passed to the linker do not have matching ident records. This means
they are for different device types.
(504) object code version is greater than *.*
(Linker)
The object code version of an object module is higher than the highest version the
linker is known to work with. Check that you are using the correct linker. Contact
Microchip Technical Support if the object file if you have not patched the linker.
2012 Microchip Technology Inc.
DS52053B-page 423
MPLAB® XC8 C Compiler User’s Guide
(505) no end record found inobject file
(Linker)
An object file did not contain an end record. This probably means the file is corrupted
or not an object file. Contact Microchip Technical Support if the object file was
generated by the compiler.
(506) object file record too long: *+*
(Linker)
This is an internal compiler error. Contact Microchip Technical Support with details.
(507) unexpected end of file in object file
(Linker)
This is an internal compiler error. Contact Microchip Technical Support with details.
(508) relocation offset (*) out of range 0..*-*-1
(Linker)
This is an internal compiler error. Contact Microchip Technical Support with details.
(509) illegal relocation size: *
(Linker)
There is an error in the object code format read by the linker. This either means you are
using a linker that is out of date, or that there is an internal error in the assembler or
linker. Contact Microchip Technical Support with details if the object file was created by
the compiler.
(510) complex relocation not supported for -R or -L options
(Linker)
The linker was given a -R or -L option with file that contain complex relocation.
(511) bad complex range check
(Linker)
This is an internal compiler error. Contact Microchip Technical Support with details.
(512) unknown complex operator 0x*
(Linker)
This is an internal compiler error. Contact Microchip Technical Support with details.
(513) bad complex relocation
(Linker)
The linker has been asked to perform complex relocation that is not syntactically
correct. Probably means an object file is corrupted.
(514) illegal relocation type: *
(Linker)
An object file contained a relocation record with an illegal relocation type. This probably
means the file is corrupted or not an object file. Contact Microchip Technical Support
with details if the object file was created by the compiler.
(515) unknown symbol type *
(Linker)
This is an internal compiler error. Contact Microchip Technical Support with details.
(516) text record has bad length: *-*-(*+1) < 0
(Linker)
This is an internal compiler error. Contact Microchip Technical Support with details.
(520) function "*" is never called
(Linker)
This function is never called. This may not represent a problem, but space could be
saved by removing it. If you believe this function should be called, check your source
code. Some assembler library routines are never called, although they are actually execute. In this case, the routines are linked in a special sequence so that program
execution falls through from one routine to the next.
(521) call depth exceeded by function "*"
(Linker)
The call graph shows that functions are nested to a depth greater than specified.
DS52053B-page 424
2012 Microchip Technology Inc.
Error and Warning Messages
(522) library "*" is badly ordered
(Linker)
This library is badly ordered. It will still link correctly, but it will link faster if better
ordered.
(523) argument to -W option (*) illegal and ignored
(Linker)
The argument to the linker option -w is out of range. This option controls two features.
For warning levels, the range is -9 to 9. For the map file width, the range is greater than
or equal to 10.
(524) unable to open list file "*": *
(Linker)
The named list file could not be opened. The linker would be trying to fixup the list file
so that it will contain absolute addresses. Ensure that an assembler list file was generated during the compilation stage. Alternatively, remove the assembler list file
generation option from the link step.
(525) too many address (memory) spaces; space (*) ignored
(Linker)
The limit to the number of address spaces (specified with the PSECT assembler
directive) is currently 16.
(526) psect "*" not specified in -P option (first appears in "*")
(Linker)
This psect was not specified in a -P or -A option to the linker. It has been linked at the
end of the program, which is probably not where you wanted it.
(528) no start record; entry point defaults to zero
(Linker)
None of the object files passed to the linker contained a start record. The start address
of the program has been set to zero. This may be harmless, but it is recommended that
you define a start address in your startup module by using the END directive.
(529) usage: objtohex [-Ssymfile] [object-file [HEX-file]]
(Objtohex)
Improper usage of the command-line tool objtohex. If you are invoking objtohex
directly then refer to Section 8.3 “OBJTOHEX” for more details. Otherwise, this may
be an internal compiler error and you should contact Microchip Technical Support with
details.
(593) can’t find 0x* words (0x* withtotal) for psect "*" in segment "*"
(Linker)
See message (491).
(594) undefined symbol:
(Linker)
The symbol following is undefined at link time. This could be due to spelling error, or
failure to link an appropriate module.
(595) undefined symbols:
(Linker)
A list of symbols follows that were undefined at link time. These errors could be due to
spelling error, or failure to link an appropriate module.
(596) segment "*" (*-*) overlaps segment "*" (*-*)
(Linker)
The named segments have overlapping code or data. Check the addresses being
assigned by the -P linker option.
(599) No psect classes given for COFF write
(Cromwell)
CROMWELL requires that the program memory psect classes be specified to produce a
COFF file. Ensure that you are using the -N option as per Section 8.5.2 “-N”.
2012 Microchip Technology Inc.
DS52053B-page 425
MPLAB® XC8 C Compiler User’s Guide
(600) No chip arch given for COFF write
(Cromwell)
CROMWELL requires that the chip architecture be specified to produce a COFF file.
Ensure that you are using the -P option as per Table 8-7.
(601) Unknown chip arch "*" for COFF write
(Cromwell)
The chip architecture specified for producing a COFF file isn’t recognized by
CROMWELL. Ensure that you are using the -P option as per
Section 8.5.1 “-Pname[,architecture]” and that the architecture specified matches
one of those in Table 8-7.
(602) null file format name
(Cromwell)
The -I or -O option to CROMWELL must specify a file format.
(603) ambiguous file format name "*"
(Cromwell)
The input or output format specified to CROMWELL is ambiguous. These formats are
specified with the -i key and -o key options respectively.
(604) unknown file format name "*"
(Cromwell)
The output format specified to CROMWELL is unknown, for example:
cromwell -m -P16F877 main.HEX main.sym -ocot
and output file type of cot, did you mean cof?
(605) did not recognize format of input file
(Cromwell)
The input file to CROMWELL is required to be COD, Intel HEX, Motorola HEX, COFF,
OMF51, P&E or HI-TECH.
(606) inconsistent symbol tables
(Cromwell)
This is an internal compiler error. Contact Microchip Technical Support with details.
(607) inconsistent line number tables
(Cromwell)
This is an internal compiler error. Contact Microchip Technical Support with details.
(608) bad path specification
(Cromwell)
This is an internal compiler error. Contact Microchip Technical Support with details.
(609) missing device spec after -P
(Cromwell)
The -p option to CROMWELL must specify a device name.
(610) missing psect classes after -N
(Cromwell)
CROMWELL requires that the -N option be given a list of the names of psect classes.
(611) too many input files
(Cromwell)
To many input files have been specified to be converted by CROMWELL.
(612) too many output files
(Cromwell)
To many output file formats have been specified to CROMWELL.
(613) no output file format specified
(Cromwell)
The output format must be specified to CROMWELL.
(614) no input files specified
(Cromwell)
CROMWELL must have an input file to convert.
DS52053B-page 426
2012 Microchip Technology Inc.
Error and Warning Messages
(616) option -Cbaseaddr is illegal with options -R or -L
(Linker)
The linker option -Cbaseaddr cannot be used in conjunction with either the -R or -L
linker options.
(618) error reading COD file data
(Cromwell)
An error occurred reading the input COD file. Confirm the spelling and path of the file
specified on the command line.
(619) I/O error reading symbol table
(Cromwell)
The COD file has an invalid format in the specified record.
(620) filename index out of range in line number record
(Cromwell)
The COD file has an invalid value in the specified record.
(621) error writing ELF/DWARF section "*" on "*"
(Cromwell)
An error occurred writing the indicated section to the given file. Confirm the spelling and
path of the file specified on the command line.
(622) too many type entries
(Cromwell)
This is an internal compiler error. Contact Microchip Technical Support with details.
(623) bad class in type hashing
(Cromwell)
This is an internal compiler error. Contact Microchip Technical Support with details.
(624) bad class in type compare
(Cromwell)
This is an internal compiler error. Contact Microchip Technical Support with details.
(625) too many files in COFF file
(Cromwell)
This is an internal compiler error. Contact Microchip Technical Support with details.
(626) string lookup failed in COFF: get_string()
(Cromwell)
This is an internal compiler error. Contact Microchip Technical Support with details.
(627) missing "*" in SDB file "*" line * column *
(Cromwell)
This is an internal compiler error. Contact Microchip Technical Support with details.
(629) bad storage class "*" in SDB file "*" line * column *
(Cromwell)
This is an internal compiler error. Contact Microchip Technical Support with details.
(630) invalid syntax for prefix list in SDB file "*"
(Cromwell)
This is an internal compiler error. Contact Microchip Technical Support with details.
(631) syntax error at token "*" in SDB file "*" line * column *
(Cromwell)
This is an internal compiler error. Contact Microchip Technical Support with details.
(632) can’t handle address size (*)
(Cromwell)
This is an internal compiler error. Contact Microchip Technical Support with details.
(633) unknown symbol class (*)
(Cromwell)
CROMWELL has encountered a symbol class in the symbol table of a COFF, Microchip
COFF, or ICOFF file which it can’t identify.
2012 Microchip Technology Inc.
DS52053B-page 427
MPLAB® XC8 C Compiler User’s Guide
(634) error dumping "*"
(Cromwell)
Either the input file to CROMWELL is of an unsupported type or that file cannot be
dumped to the screen.
(635) invalid HEX file "*" on line *
(Cromwell)
The specified HEX file contains an invalid line. Contact Microchip Technical Support if
the HEX file was generated by the compiler.
(636) checksum error in Intel HEX file "*" on line *
(Cromwell, Hexmate)
A checksum error was found at the specified line in the specified Intel HEX file. The
HEX file may be corrupt.
(637) unknown prefix "*" in SDB file "*"
(Cromwell)
This is an internal compiler warning. Contact Microchip Technical Support with details.
(638) version mismatch: 0x* expected
(Cromwell)
The input Microchip COFF file wasn’t produced using CROMWELL.
(639) zero bit width in Microchip optional header
(Cromwell)
The optional header in the input Microchip COFF file indicates that the program or data
memory spaces are zero bits wide.
(668) prefix list did not match any SDB types
(Cromwell)
This is an internal compiler error. Contact Microchip Technical Support with details.
(669) prefix list matched more than one SDB type
(Cromwell)
This is an internal compiler error. Contact Microchip Technical Support with details.
(670) bad argument to -T
(Clist)
The argument to the -T option to specify tab size was not present or correctly formed.
The option expects a decimal integer argument.
(671) argument to -T should be in range 1 to 64
(Clist)
The argument to the -T option to specify tab size was not in the expected range. The
option expects a decimal integer argument ranging from 1 to 64 inclusive.
(673) missing filename after * option
(Objtohex)
The indicated option requires a valid file name. Ensure that the filename argument supplied to this option exists and is spelt correctly.
(674) too many references to "*"
(Cref)
This is an internal compiler error. Contact Microchip Technical Support with details.
(677) set_fact_bit on pic17!
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(678) case 55 on pic17!
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(679) unknown extraspecial: *
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(680) bad format for -P option
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
DS52053B-page 428
2012 Microchip Technology Inc.
Error and Warning Messages
(681) bad common spec in -P option
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(682) this architecture is not supported by the PICC™ Lite compiler
(Code Generator)
A target device other than baseline, mid-range or highend was specified. This compiler
only supports devices from these architecture families.
(683) bank 1 variables are not supported by the PICC Lite compiler
(Code Generator)
A variable with an absolute address located in bank 1 was detected. This compiler does
not support code generation of variables in this bank.
(684) bank 2 and 3 variables are not supported by the PICC Lite compiler
(Code Generator)
A variable with an absolute address located in bank 2 or 3 was detected. This compiler
does not support code generation of variables in these banks.
(685) bad putwsize()
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(686) bad switch size (*)
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(687) bad pushreg "*"
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(688) bad popreg "*"
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(689) unknown predicate "*"
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(690) interrupt function requires address
(Code Generator)
The high end PIC devices support multiple interrupts. An @ address is required with the
interrupt definition to indicate with which vector this routine is associated, for example:
void interrupt isr(void) @ 0x10
{
/* isr code goes here */
}
This construct is not required for mid-range PIC devices.
(691) interrupt functions not implemented for 12 bit PIC MCU
(Code Generator)
The 12-bit range of PIC MCU processors do not support interrupts.
(692) interrupt function "*" may only have one interrupt level
(Code Generator)
Only one interrupt level may be associated with an interrupt function. Check to
ensure that only one interrupt_level pragma has been used with the function
specified. This pragma may be used more than once on main-line functions that are
called from interrupt functions. For example:
#pragma interrupt_level 0
#pragma interrupt_level 1
void interrupt isr(void)
{
2012 Microchip Technology Inc.
/* which is it to be: 0 or 1? */
DS52053B-page 429
MPLAB® XC8 C Compiler User’s Guide
(693) interrupt level may only be 0 (default) or 1
(Code Generator)
The only possible interrupt levels are 0 or 1. Check to ensure that all
interrupt_level pragmas use these levels.
#pragma interrupt_level 2 /* oops -- only 0 or 1 */
void interrupt isr(void)
{
/* isr code goes here */
}
(694) no interrupt strategy available
(Code Generator)
The device does not support saving and subsequent restoring of registers during an
interrupt service routine.
(695) duplicate case label (*)
(Code Generator)
There are two case labels with the same value in this switch statement, for example:
switch(in) {
case ’0’: /* if this is case ’0’... */
b++;
break;
case ’0’: /* then what is this case? */
b--;
break;
}
(696) out-of-range case label (*)
(Code Generator)
This case label is not a value that the controlling expression can yield, and thus this
label will never be selected.
(697) non-constant case label
(Code Generator)
A case label in this switch statement has a value which is not a constant.
(698) bit variables must be global or static
(Code Generator)
A bit variable cannot be of type auto. If you require a bit variable with scope local
to a block of code or function, qualify it static, for example:
bit proc(int a)
{
bit bb;
/* oops -bb = (a > 66);
return bb;
}
this should be: static bit bb; */
(699) no case labels in switch
(Code Generator)
There are no case labels in this switch statement, for example:
switch(input) {
}
/* there is nothing to match the value of input */
(700) truncation of enumerated value
(Code Generator)
An enumerated value larger than the maximum value supported by this compiler was
detected and has been truncated, for example:
enum { ZERO, ONE, BIG=0x99999999 } test_case;
(701) unreasonable matching depth
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
DS52053B-page 430
2012 Microchip Technology Inc.
Error and Warning Messages
(702) regused(): bad arg to G
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(703) bad GN
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(704) bad RET_MASK
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(705) bad which (*) after I
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(706) bad which in expand()
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(707) bad SX
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(708) bad mod "+" for how = "*"
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(709) metaregister "*" can’t be used directly
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(710) bad U usage
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(711) bad how in expand()
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(712) can’t generate code for this expression
(Code Generator)
This error indicates that a C expression is too difficult for the code generator to actually
compile. For successful code generation, the code generator must know how to compile an expression and there must be enough resources (i.e., registers or temporary
memory locations) available. Simplifying the expression, i.e., using a temporary variable to hold an intermediate result, may work around this message. Contact Microchip
Technical Support with details of this message.
This error may also be issued if the code being compiled is unusual. For example, code
which writes to a const-qualified object is illegal and will result in warning messages,
but the code generator may unsuccessfully try to produce code to perform the write.
(713) bad initialization list
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(714) bad intermediate code
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(715) bad pragma "*"
(Code Generator)
The code generator has been passed a pragma directive that it does not understand.
This implies that the pragma you have used is not implemented for the target device.
2012 Microchip Technology Inc.
DS52053B-page 431
MPLAB® XC8 C Compiler User’s Guide
(716) bad argument to -M option "*"
(Code Generator)
The code generator has been passed a -M option that it does not understand. This
should not happen if it is being invoked by a standard compiler driver.
(718) incompatible intermediate code version; should be *.*
(Code Generator)
The intermediate code file produced by P1 is not the correct version for use with this
code generator. This is either that incompatible versions of one or more compilers have
been installed in the same directory, or a temporary file error has occurred leading to
corruption of a temporary file. Check the setting of the TEMP environment variable. If
it refers to a long path name, change it to something shorter. Contact Microchip
Technical Support with details if required.
(720) multiple free: *
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(721) element count must be constant expression
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(722) bad variable syntax in intermediate code
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(723) function definitions nested too deep
(Code Generator)
This error is unlikely to happen with C code, since C cannot have nested functions!
Contact Microchip Technical Support with details.
(724) bad op (*) in revlog()
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(726) bad op "*" in uconval()
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(727) bad op "*" in bconfloat()
(Code Generator)
This is an internal code generator error. Contact Microchip Technical Support with
details.
(728) bad op "*" in confloat()
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(729) bad op "*" in conval()
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(730) bad op "*" (
Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(731) expression error with reserved word
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(732) initialization of bit types is illegal
(Code Generator)
Variables of type bit cannot be initialized, for example:
bit b1 = 1; /* oops!
b1 must be assigned after its definition */
DS52053B-page 432
2012 Microchip Technology Inc.
Error and Warning Messages
(733) bad string "*" in pragma "psect"
(Code Generator)
The code generator has been passed a pragma psect directive that has a badly
formed string, for example:
#pragma psect text
/* redirect text psect into what? */
Maybe you meant something like:
#pragma psect text=special_text
(734) too many "psect" pragmas
(Code Generator)
Too many #pragma psect directives have been used.
(735) bad string "*" in pragma "stack_size"
(Code Generator)
The argument to the stack_size pragma is malformed. This pragma must be followed
by a number representing the maximum allowed stack size.
(737) unknown argument "*" to pragma "switch"
(Code Generator)
The #pragma switch directive has been used with an invalid switch code generation
method. Possible arguments are: auto , simple and direct.
(739) error closing output file
(Code Generator)
The compiler detected an error when closing a file. Contact Microchip Technical
Support with details.
(740) zero dimension array is illegal
(Code Generator)
The code generator has been passed a declaration that results in an array having a
zero dimension.
(741) bitfield too large (* bits)
(Code Generator)
The maximum number of bits in a bit-field is 8, the same size as the storage unit width.
struct {
unsigned flag : 1;
unsigned value : 12;
unsigned cont : 6;
} object;
/* oops -- that’s larger than 8 bits wide */
(742) function "*" argument evaluation overlapped
(Linker)
A function call involves arguments which overlap between two functions. This could
occur with a call like:
void fn1(void)
{
fn3( 7, fn2(3), fn2(9));
/* Offending call */
}
char fn2(char fred)
{
return fred + fn3(5,1,0);
}
char fn3(char one, char two, char three)
{
return one+two+three;
}
where fn1 is calling fn3 , and two arguments are evaluated by calling fn2 , which in
turn calls fn3. The program structure should be modified to prevent this type of call
sequence.
2012 Microchip Technology Inc.
DS52053B-page 433
MPLAB® XC8 C Compiler User’s Guide
(743) divide by zero
(Code Generator)
An expression involving a division by zero has been detected in your code.
(744) static object "*" has zero size
(Code Generator)
A static object has been declared, but has a size of zero.
(745) nodecount = *
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(746) object "*" qualified const, but not initialized
(Code Generator)
An object has been qualified as const, but there is no initial value supplied at the definition. As this object cannot be written by the C program, this may imply the initial value
was accidently omitted.
(747) unrecognized option "*" to -Z
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(748) variable "*" may be used before set
(Code Generator)
This variable may be used before it has been assigned a value. Since it is an auto variable, this will result in it having a random value, for example:
void main(void)
{
int a;
if(a)
/* oops -- a has never been assigned a value */
process();
}
(749) unknown register name "*" used with pragma
(Linker)
This is an internal compiler error. Contact Microchip Technical Support with details.
DS52053B-page 434
2012 Microchip Technology Inc.
Error and Warning Messages
MESSAGES 750-999
(750) constant operand to || or &&
(Code Generator)
One operand to the logical operators || or && is a constant. Check the expression for
missing or badly placed parentheses. This message may also occur if the global optimizer is enabled and one of the operands is an auto or static local variable whose
value has been tracked by the code generator, for example:
{
int a;
a = 6;
if(a || b)
b++;
/* a is 6, therefore this is always true */
(751) arithmetic overflow in constant expression
(Code Generator)
A constant expression has been evaluated by the code generator that has resulted in
a value that is too big for the type of the expression. The most common code to trigger
this warning is assignments to signed data types. For example:
signed char c;
c = 0xFF;
As a signed 8-bit quantity, c can only be assigned values -128 to 127. The constant
is equal to 255 and is outside this range. If you mean to set all bits in this variable, then
use either of:
c = ~0x0;
c = -1;
which sets all the bits in the variable, regardless of variable size, and without warning.
This warning can also be triggered by intermediate values overflowing. For example:
unsigned int i;
i = 240 * 137;
/* assume ints are 16 bits wide */
/* this should be okay, right? */
A quick check with your calculator reveals that 240 * 137 is 32880 which can easily be
stored in an unsigned int, but a warning is produced. Why? Because 240 and 137
and both signed int values. Therefore the result of the multiplication must also be
a signed int value, but a signed int cannot hold the value 32880. (Both operands
are constant values so the code generator can evaluate this expression at compile
time, but it must do so following all the ANSI C rules.) The following code forces the
multiplication to be performed with an unsigned result:
i = 240u * 137;
/* force at least one operand
to be unsigned */
(752) conversion to shorter data type
(Code Generator)
Truncation may occur in this expression as the lvalue is of shorter type than the
rvalue, for example:
char a;
int b, c;
a = b + c;
/* int to char conversion
may result in truncation */
(753) undefined shift (* bits)
(Code Generator)
An attempt has been made to shift a value by a number of bits equal to or greater than
the number of bits in the data type. This will produce an undefined result on many processors. This is non-portable code and is flagged as having undefined results by the C
Standard, for example:
int input;
input = 0)
will always be true, because an unsigned value can never be less than zero.
(766) degenerate signed comparison
(Code Generator)
There is a comparison of a signed value with the most negative value possible for this
type, such that the comparison will always be true or false, for example:
char c;
if(c >= -128)
will always be true, because an 8 bit signed char has a maximum negative value of
-128.
(767) constant truncated to bitfield width
(Code Generator)
A constant value is too large for a bit-field structure member on which it is operating,
for example:
struct INPUT {
unsigned a : 3;
unsigned b : 5;
} input_grp;
input_grp.a |= 0x13;
*/
DS52053B-page 438
/* oops -- 0x13 to large for 3-bit wide object
2012 Microchip Technology Inc.
Error and Warning Messages
(768) constant relational expression
(Code Generator)
There is a relational expression that will always be true or false. This, for example, may
be the result of comparing an unsigned number with a negative value; or comparing
a variable with a value greater than the largest number it can represent, for example:
unsigned int a;
if(a == -10)
/* if a is unsigned, how can it be -10? */
b = 9;
(769) no space for macro definition
(Assembler)
The assembler has run out of memory.
(772) include files nested too deep
(Assembler)
Macro expansions and include file handling have filled up the assembler’s internal
stack. The maximum number of open macros and include files is 30.
(773) macro expansions nested too deep
(Assembler)
Macro expansions in the assembler are nested too deep. The limit is 30 macros and
include files nested at one time.
(774) too many macro parameters
(Assembler)
There are too many macro parameters on this macro definition.
(776) can’t allocate space for object "*" (offs: *)
(Assembler)
The assembler has run out of memory.
(777) can’t allocate space for opnd structure within object "*", (offs: *)
(Assembler)
The assembler has run out of memory.
(780) too many psects defined
(Assembler)
There are too many psects defined! Boy, what a program!
(781) can’t enter abs psect
(Assembler)
This is an internal compiler error. Contact Microchip Technical Support with details.
(782) REMSYM error
(Assembler)
This is an internal compiler error. Contact Microchip Technical Support with details.
(783) "with" psects are cyclic
(Assembler)
If Psect A is to be placed “with” Psect B, and Psect B is to be placed “with” Psect A,
there is no hierarchy. The with flag is an attribute of a psect and indicates that this
psect must be placed in the same memory page as the specified psect.
Remove a with flag from one of the psect declarations. Such an assembler
declaration may look like:
psect my_text,local,class=CODE,with=basecode
which will define a psect called my_text and place this in the same page as the psect
basecode.
(784) overfreed
(Assembler)
This is an internal compiler error. Contact Microchip Technical Support with details.
(785) too many temporary labels
(Assembler)
There are too many temporary labels in this assembler file. The assembler allows a
maximum of 2000 temporary labels.
2012 Microchip Technology Inc.
DS52053B-page 439
MPLAB® XC8 C Compiler User’s Guide
(787) can’t handle "v_rtype" of * in copyexpr
(Assembler)
This is an internal compiler error. Contact Microchip Technical Support with details.
(788) invalid character "*" in number
(Assembler)
A number contained a character that was not part of the range 0-9 or 0-F.
(790) end of file inside conditional
(Assembler)
END-of-FILE was encountered while scanning for an “endif” to match a previous “if”.
(793) unterminated macro argument
(Assembler)
An argument to a macro is not terminated. Note that angle brackets (“< >”) are used to
quote macro arguments.
(794) invalid number syntax
(Assembler)
The syntax of a number is invalid. This, for example, can be use of 8 or 9 in an octal
number, or other malformed numbers.
(796) use of LOCAL outside macros is illegal
(Assembler)
The LOCAL directive is only legal inside macros. It defines local labels that will be
unique for each invocation of the macro.
(797) syntax error in LOCAL argument
(Assembler)
A symbol defined using the LOCAL assembler directive in an assembler macro is syntactically incorrect. Ensure that all symbols and all other assembler identifiers conform
with the assembly language of the target device.
(798) macro argument may not appear after LOCAL
(Assembler)
The list of labels after the directive LOCAL may not include any of the formal parameters
to the macro, for example:
mmm MACRO a1
MOVE
r0, #a1
LOCAL a1
; oops -; the macro parameter cannot be used with local
ENDM
(799) REPT argument must be >= 0
(Assembler)
The argument to a REPT directive must be greater than zero, for example:
REPT -2
MOVE
ENDM
; -2 copies of this code? */
r0, [r1]++
(800) undefined symbol "*"
(Assembler)
The named symbol is not defined in this module, and has not been specified GLOBAL.
(801) range check too complex
(Assembler)
This is an internal compiler error. Contact Microchip Technical Support with details.
(802) invalid address after END directive
(Assembler)
The start address of the program which is specified after the assembler END directive
must be a label in the current file.
(803) undefined temporary label
(Assembler)
A temporary label has been referenced that is not defined. Note that a temporary label
must have a number >= 0.
DS52053B-page 440
2012 Microchip Technology Inc.
Error and Warning Messages
(804) write error on object file
(Assembler)
The assembler failed to write to an object file. This may be an internal compiler error.
Contact Microchip Technical Support with details.
(806) attempted to get an undefined object (*)
(Assembler)
This is an internal compiler error. Contact Microchip Technical Support with details.
(807) attempted to set an undefined object (*)
(Assembler)
This is an internal compiler error. Contact Microchip Technical Support with details.
(808) bad size in add_reloc()
(Assembler)
This is an internal compiler error. Contact Microchip Technical Support with details.
(809) unknown addressing mode (*)
(Assembler)
An unknown addressing mode was used in the assembly file.
(811) "cnt" too large (*) in display()
(Assembler)
This is an internal compiler error. Contact Microchip Technical Support with details.
(814) device type not defined
(Assembler)
The device must be defined either from the command line (eg. -16c84), via the device
assembler directive, or via the LIST assembler directive.
(815) syntax error in chipinfo file at line *
(Assembler)
The chipinfo file contains non-standard syntax at the specified line.
(816) duplicate ARCH specification in chipinfo file "*" at line *
(Assembler, Driver)
The chipinfo file has a device section with multiple ARCH values. Only one ARCH value
is allowed. If you have not manually edited the chip info file, contact Microchip Technical
Support with details.
(817) unknown architecture in chipinfo file at line *
(Assembler, Driver)
An chip architecture (family) that is unknown was encountered when reading the chip
INI file.
(818) duplicate BANKS for "*" in chipinfo file at line *
(Assembler)
The chipinfo file has a device section with multiple BANKS values. Only one BANKS
value is allowed. If you have not manually edited the chip info file, contact Microchip
Technical Support with details.
(819) duplicate ZEROREG for "*" in chipinfo file at line *
(Assembler)
The chipinfo file has a device section with multiple ZEROREG values. Only one
ZEROREG value is allowed. If you have not manually edited the chip info file, contact
Microchip Technical Support with details.
(820) duplicate SPAREBIT for "*" in chipinfo file at line *
(Assembler)
The chipinfo file has a device section with multiple SPAREBIT values. Only one
SPAREBIT value is allowed. If you have not manually edited the chip info file, contact
Microchip Technical Support with details.
(821) duplicate INTSAVE for "*" in chipinfo file at line *
(Assembler)
The chipinfo file has a device section with multiple INTSAVE values. Only one
INTSAVE value is allowed. If you have not manually edited the chip info file, contact
Microchip Technical Support with details.
2012 Microchip Technology Inc.
DS52053B-page 441
MPLAB® XC8 C Compiler User’s Guide
(822) duplicate ROMSIZE for "*" in chipinfo file at line *
(Assembler)
The chipinfo file has a device section with multiple ROMSIZE values. Only one
ROMSIZE value is allowed. If you have not manually edited the chip info file, contact
Microchip Technical Support with details.
(823) duplicate START for "*" in chipinfo file at line *
(Assembler)
The chipinfo file has a device section with multiple START values. Only one START
value is allowed. If you have not manually edited the chip info file, contact Microchip
Technical Support with details.
(824) duplicate LIB for "*" in chipinfo file at line *
(Assembler)
The chipinfo file has a device section with multiple LIB values. Only one LIB value is
allowed. If you have not manually edited the chip info file, contact Microchip Technical
Support with details.
(825) too many RAMBANK lines in chipinfo file for "*"
(Assembler)
The chipinfo file contains a device section with too many RAMBANK fields. Reduce the
number of values.
(826) inverted ram bank in chipinfo file at line *
(Assembler, Driver)
The second HEX number specified in the RAM field in the chipinfo file must be greater
in value than the first.
(827) too many COMMON lines in chipinfo file for "*"
(Assembler)
There are too many lines specifying common (access bank) memory in the chip
configuration file.
(828) inverted common bank in chipinfo file at line *
(Assembler, Driver)
The second HEX number specified in the COMMON field in the chipinfo file must be
greater in value than the first. Contact Microchip Technical Support if you have not
modified the chipinfo INI file.
(829) unrecognized line in chipinfo file at line *
(Assembler)
The chipinfo file contains a device section with an unrecognized line. Contact Microchip
Technical Support if the INI has not been edited.
(830) missing ARCH specification for "*" in chipinfo file
(Assembler)
The chipinfo file has a device section without an ARCH values. The architecture of the
device must be specified. Contact Microchip Technical Support if the chipinfo file has
not been modified.
(832) empty chip info file "*"
(Assembler)
The chipinfo file contains no data. If you have not manually edited the chip info file, contact Microchip Technical Support with details.
(833) no valid entries in chipinfo file
(Assembler)
The chipinfo file contains no valid device descriptions.
(834) page width must be >= 60
(Assembler)
The listing page width must be at least 60 characters. Any less will not allow a properly
formatted listing to be produced, for example:
LIST C=10
DS52053B-page 442
; the page width will need to be wider than this
2012 Microchip Technology Inc.
Error and Warning Messages
(835) form length must be >= 15
(Assembler)
The form length specified using the -F length option must be at least 15 lines. Setting
this length to zero is allowed and turns off paging altogether. The default value is zero
(pageless).
(836) no file arguments
(Assembler)
The assembler has been invoked without any file arguments. It cannot assemble
anything.
(839) relocation too complex
(Assembler)
The complex relocation in this expression is too big to be inserted into the object file.
(840) phase error
(Assembler)
The assembler has calculated a different value for a symbol on two different passes.
This is probably due to bizarre use of macros or conditional assembly.
(841) bad source/destination for movfp/movpf instruction
(Assembler)
The absolute address specified with the MOVFP/MOVPF instruction is too large.
(842) bad bit number
(Assembler)
A bit number must be an absolute expression in the range 0-7.
(843) a macro name can’t also be an EQU/SET symbol
(Assembler)
An EQU or SET symbol has been found with the same name as a macro. This is not
allowed. For example:
getval MACRO
MOV r0, r1
ENDM
getval EQU 55h
; oops -- choose a different name to the macro
(844) lexical error
(Assembler)
An unrecognized character or token has been seen in the input.
(845) symbol "*" defined more than once
(Assembler)
This symbol has been defined in more than one place. The assembler will issue this
error if a symbol is defined more than once in the same module, for example:
_next:
MOVE
MOVE
_next:
r0, #55
[r1], r0
; oops -- choose a different name
The linker will issue this warning if the symbol (C or assembler) was defined multiple
times in different modules. The names of the modules are given in the error message.
Note that C identifiers often have an underscore prepended to their name after compilation.
(846) relocation error
(Assembler)
It is not possible to add together two relocatable quantities. A constant may be added
to a relocatable value, and two relocatable addresses in the same psect may be subtracted. An absolute value must be used in various places where the assembler must
know a value at assembly time.
(847) operand error
(Assembler)
The operand to this opcode is invalid. Check your assembler reference manual for the
proper form of operands for this instruction.
2012 Microchip Technology Inc.
DS52053B-page 443
MPLAB® XC8 C Compiler User’s Guide
(848) symbol has been declared EXTERN
(Assembler)
An assembly label uses the same name as a symbol that has already been declared
as EXTERN.
(849) illegal instruction for this device
(Assembler)
The instruction is not supported by this device.
(850) PAGESEL not usable with this device
(Assembler)
The PAGESEL pseudo-instruction is not usable with the device selected.
(851) illegal destination
(Assembler)
The destination (either ,f or ,w ) is not correct for this instruction.
(852) radix must be from 2 - 16
(Assembler)
The radix specified using the RADIX assembler directive must be in the range from 2
(binary) to 16 (hexadecimal).
(853) invalid size for FNSIZE directive
(Assembler)
The assembler FNSIZE assembler directive arguments must be positive constants.
(855) ORG argument must be a positive constant
(Assembler)
An argument to the ORG assembler directive must be a positive constant or a symbol
which has been equated to a positive constant, for example:
ORG -10
/* this must a positive offset to the current psect */
(856) ALIGN argument must be a positive constant
(Assembler)
The align assembler directive requires a non-zero positive integer argument.
(857) psect may not be local and global
(Linker)
A local psect may not have the same name as a global psect, for example:
psect text,class=CODE
; text is implicitly global
MOVE
r0, r1
; elsewhere:
psect text,local,class=CODE
MOVE
r2, r4
The global flag is the default for a psect if its scope is not explicitly stated.
(859) argument to C option must specify a positive constant
(Assembler)
The parameter to the LIST assembler control’s C= option (which sets the column width
of the listing output) must be a positive decimal constant number, for example:
LIST C=a0h
; constant must be decimal and positive,
try: LIST C=80
(860) page width must be >= 49
(Assembler)
The page width suboption to the LIST assembler directive must specify a width of at
least 49.
(861) argument to N option must specify a positive constant
(Assembler)
The parameter to the LIST assembler control’s N option (which sets the page length
for the listing output) must be a positive constant number, for example:
LIST N=-3
DS52053B-page 444
; page length must be positive
2012 Microchip Technology Inc.
Error and Warning Messages
(862) symbol is not external
(Assembler)
A symbol has been declared as EXTRN but is also defined in the current module.
(863) symbol can’t be both extern and public
(Assembler)
If the symbol is declared as extern, it is to be imported. If it is declared as public, it is to
be exported from the current module. It is not possible for a symbol to be both.
(864) argument to "size" psect flag must specify a positive constant
(Assembler)
The parameter to the PSECT assembler directive’s size option must be a positive constant number, for example:
PSECT text,class=CODE,size=-200
; a negative size?
(865) psect flag "size" redefined
(Assembler)
The size flag to the PSECT assembler directive is different from a previous PSECT
directive, for example:
psect spdata,class=RAM,size=400
; elsewhere:
psect spdata,class=RAM,size=500
(866) argument to "reloc" psect flag must specify a positive constant
(Assembler)
The parameter to the PSECT assembler directive’s reloc option must be a positive
constant number, for example:
psect test,class=CODE,reloc=-4
; the reloc must be positive
(867) psect flag "reloc" redefined
(Assembler)
The reloc flag to the PSECT assembler directive is different from a previous PSECT
directive, for example:
psect spdata,class=RAM,reloc=4
; elsewhere:
psect spdata,class=RAM,reloc=8
(868) argument to "delta" psect flag must specify a positive constant
(Assembler)
The parameter to the PSECT assembler directive’s DELTA option must be a positive
constant number, for example:
PSECT text,class=CODE,delta=-2
sense
; negative delta value doesn’t make
(869) psect flag "delta" redefined
(Assembler)
The ’DELTA’ option of a psect has been redefined more than once in the same module.
(870) argument to "pad" psect flag must specify a positive constant
(Assembler)
The parameter to the PSECT assembler directive’s ’PAD’ option must be a non-zero
positive integer.
(871) argument to "space" psect flag must specify a positive constant
(Assembler)
The parameter to the PSECT assembler directive’s space option must be a positive
constant number, for example:
PSECT text,class=CODE,space=-1
2012 Microchip Technology Inc.
; space values start at zero
DS52053B-page 445
MPLAB® XC8 C Compiler User’s Guide
(872) psect flag "space" redefined
(Assembler)
The space flag to the PSECT assembler directive is different from a previous PSECT
directive, for example:
psect spdata,class=RAM,space=0
; elsewhere:
psect spdata,class=RAM,space=1
(873) a psect may only be in one class
(Assembler)
You cannot assign a psect to more than one class. The psect was defined differently at
this point than when it was defined elsewhere. A psect’s class is specified via a flag as
in the following:
psect text,class=CODE
Look for other psect definitions that specify a different class name.
(874) a psect may only have one "with" option
(Assembler)
A psect can only be placed with one other psect. A psect’s with option is specified via
a flag as in the following:
psect bss,with=data
Look for other psect definitions that specify a different with psect name.
(875) bad character constant in expression
(Assembler)
The character constant was expected to consist of only one character, but was found
to be greater than one character or none at all. An assembler specific example:
MOV
r0, #’12’
; ’12’ specifies two characters
(876) syntax error
(Assembler)
A syntax error has been detected. This could be caused a number of things.
(877) yacc stack overflow
(Assembler)
This is an internal compiler error. Contact Microchip Technical Support with details.
(878) -S option used: "*" ignored
(Driver)
The indicated assembly file has been supplied to the driver in conjunction with the -S
option. The driver really has nothing to do since the file is already an assembly file.
(880) invalid number of parameters. Use "* –HELP" for help
(Driver)
Improper command-line usage of the of the compiler’s driver.
(881) setup succeeded
(Driver)
The compiler has been successfully setup using the --setup driver option.
(883) setup failed
(Driver)
The compiler was not successfully setup using the --setup driver option. Ensure that
the directory argument to this option is spelt correctly, is syntactically correct for your
host operating system and it exists.
DS52053B-page 446
2012 Microchip Technology Inc.
Error and Warning Messages
(884) please ensure you have write permissions to the configuration file
(Driver)
The compiler was not successfully setup using the --setup driver option because the
driver was unable to access the XML configuration file. Ensure that you have write permission to this file. The driver will search the following configuration files in order:
• the file specified by the environment variable XC_XML
• the file /etc/xc.xml if the directory ’/etc ’ is writable and there is no .xc.xml
file in your home directory
• the file .xc.xml file in your home directory
If none of the files can be located, then the above error will occur.
(889) this * compiler has expired
(Driver)
The demo period for this compiler has concluded.
(890) contact Microchip to purchase and re-activate this compiler
(Driver)
The evaluation period of this demo installation of the compiler has expired. You will
need to purchase the compiler to re-activate it. If, however, you sincerely believe the
evaluation period has ended prematurely, contact Microchip technical support.
(891) can’t open psect usage map file "*": *
(Driver)
The driver was unable to open the indicated file. The psect usage map file is generated
by the driver when the driver option --summary=file is used. Ensure that the file is
not open in another application.
(892) can’t open memory usage map file "*": *
(Driver)
The driver was unable to open the indicated file. The memory usage map file is generated by the driver when the driver option --summary=file is used. Ensure that the
file is not open in another application.
(893) can’t open HEX usage map file "*": *
(Driver)
The driver was unable to open the indicated file. The HEX usage map file is generated
by the driver when the driver option --summary=file is used. Ensure that the file is
not open in another application.
(894) unknown source file type "*"
(Driver)
The extension of the indicated input file could not be determined. Only files with the
extensions as, c, obj, usb, p1, lib or HEX are identified by the driver.
(895) can’t request and specify options in the one command
(Driver)
The usage of the driver options --getoption and --setoption is mutually
exclusive.
(896) no memory ranges specified for data space
(Driver)
No on-chip or external memory ranges have been specified for the data space memory
for the device specified.
(897) no memory ranges specified for program space
(Driver)
No on-chip or external memory ranges have been specified for the program space
memory for the device specified.
2012 Microchip Technology Inc.
DS52053B-page 447
MPLAB® XC8 C Compiler User’s Guide
(899) can’t open option file "*" for application "*": *
(Driver)
An option file specified by a --getoption or --setoption driver option could not
be opened. If you are using the --setoption option ensure that the name of the file
is spelt correctly and that it exists. If you are using the --getoption option ensure
that this file can be created at the given location or that it is not in use by any other
application.
(900) exec failed: *
(Driver)
The subcomponent listed failed to execute. Does the file exist? Try re-installing the
compiler.
(902) no chip name specified; use "* –CHIPINFO" to see available chip names
(Driver)
The driver was invoked without selecting what chip to build for. Running the driver with
the –CHIPINFO option will display a list of all chips that could be selected to build for.
(904) illegal format specified in "*" option
(Driver)
The usage of this option was incorrect. Confirm correct usage with –HELP or refer to
the part of the manual that discusses this option.
(905) illegal application specified in "*" option
(Driver)
The application given to this option is not understood or does not belong to the
compiler.
(907) unknown memory space tag "*" in "*" option specification
(Driver)
A parameter to this memory option was a string but did not match any valid tags. Refer
to the section of this manual that describes this option to see what tags (if any) are valid
for this device.
(908) exit status = *
(Driver)
One of the subcomponents being executed encountered a problem and returned an
error code. Other messages should have been reported by the subcomponent to
explain the problem that was encountered.
(913) "*" option may cause compiler errors in some standard header files
(Driver)
Using this option will invalidate some of the qualifiers used in the standard header files,
resulting in errors. This issue and its solution are detailed in the section of this manual
that specifically discusses this option.
(915) no room for arguments
(Preprocessor, Parser, Code Generator, Linker, Objtohex)
The code generator could not allocate any more memory.
(917) argument too long
(Preprocessor, Parser)
This is an internal compiler error. Contact Microchip Technical Support with details.
(918) *: no match
(Preprocessor, Parser)
This is an internal compiler error. Contact Microchip Technical Support with details.
(919) * in chipinfo file "*" at line *
(Driver)
The specified parameter in the chip configuration file is illegal.
(920) empty chipinfo file
(Driver, Assembler)
The chip configuration file was able to be opened but it was empty. Try re-installing the
compiler.
DS52053B-page 448
2012 Microchip Technology Inc.
Error and Warning Messages
(922) chip "*" not present in chipinfo file "*"
(Driver)
The chip selected does not appear in the compiler’s chip configuration file. Contact
Microchip to see whether support for this device is available or it is necessary to
upgrade the version of your compiler.
(923) unknown suboption "*"
(Driver)
This option can take suboptions, but this suboption is not understood. This may just be
a simple spelling error. If not, –HELP to look up what suboptions are permitted here.
(924) missing argument to "*" option
(Driver)
This option expects more data but none was given. Check the usage of this option.
(925) extraneous argument to "*" option
(Driver)
This option does not accept additional data, yet additional data was given. Check the
usage of this option.
(926) duplicate "*" option
(Driver)
This option can only appear once, but appeared more than once.
(928) bad "*" option value
(Driver, Assembler)
The indicated option was expecting a valid hexadecimal integer argument.
(929) bad "*" option ranges
(Driver)
This option was expecting a parameter in a range format
(start_of_range-end_of_range), but the parameter did not conform to this syntax.
(930) bad "*" option specification
(Driver)
The parameters to this option were not specified correctly. Run the driver with –HELP
or refer to the driver’s chapter in this manual to verify the correct usage of this option.
(931) command file not specified
(Driver)
Command file to this application, expected to be found after ’@’ or ’a = 9;
/* data is a structure,
not a pointer to a structure */
(982) unknown op "*" in nxtuse()
(Assembler)
This is an internal compiler error. Contact Microchip Technical Support with details.
(983) storage class redeclared
(Parser)
A variable previously declared as being static , has now be redeclared as extern.
(984) type redeclared
(Parser)
The type of this function or object has been redeclared. This can occur because of two
incompatible declarations, or because an implicit declaration is followed by an incompatible declaration, for example:
int a;
char a;
/* oops -- what is the correct type? */
(985) qualifiers redeclared
(Parser)
This function or variable has different qualifiers in different declarations.
(986) enum member redeclared
(Parser)
A member of an enumeration is defined twice or more with differing values. Does the
member appear twice in the same list or does the name of the member appear in more
than one enum list?
(987) arguments redeclared
(Parser)
The data types of the parameters passed to this function do not match its prototype.
(988) number of arguments redeclared
(Parser)
The number of arguments in this function declaration does not agree with a previous
declaration of the same function.
DS52053B-page 452
2012 Microchip Technology Inc.
Error and Warning Messages
(989) module has code below file base of *h
(Linker)
This module has code below the address given, but the -C option has been used to
specify that a binary output file is to be created that is mapped to this address. This
would mean code from this module would have to be placed before the beginning of
the file! Check for missing psect directives in assembler files.
(990) modulus by zero in #if; zero result assumed
(Preprocessor)
A modulus operation in a #if expression has a zero divisor. The result has been
assumed to be zero, for example:
#define ZERO 0
#if FOO%ZERO
/* this will have an assumed result of 0 */
#define INTERESTING
#endif
(991) integer expression required
(Parser)
In an enum declaration, values may be assigned to the members, but the expression
must evaluate to a constant of type int, for example:
enum {one = 1, two, about_three = 3.12};
/* no non-int values allowed */
(992) can’t find op
(Assembler)
This is an internal compiler error. Contact Microchip Technical Support with details.
(993) some command-line options are disabled
(Driver)
The compiler is operating in demo mode. Some command-line options are disabled.
(994) some command-line options are disabled and compilation is delayed
(Driver)
The compiler is operating in demo mode. Some command-line options are disabled,
the compilation speed will be slower.
(995) some command-line options are disabled, code size is limited to 16kB, compilation is delayed
(Driver)
The compiler is operating in demo mode. Some command-line options are disabled;
the compilation speed will be slower, and the maximum allowed code size is limited to
16 KB.
2012 Microchip Technology Inc.
DS52053B-page 453
MPLAB® XC8 C Compiler User’s Guide
MESSAGES 1000-1249
(1015) missing "*" specification in chipinfo file "*" at line *
(Driver)
This attribute was expected to appear at least once but was not defined for this chip.
(1016) missing argument* to "*" specification in chipinfo file "*" at line *
(Driver)
This value of this attribute is blank in the chip configuration file.
(1017) extraneous argument* to "*" specification in chipinfo file "*" at line *
(Driver)
There are too many attributes for the listed specification in the chip configuration file.
(1018) illegal number of "*" specification* (* found; * expected) in chipinfo file "*" at line *
(Driver)
This attribute was expected to appear a certain number of times; but, it did not appear
for this chip.
(1019) duplicate "*" specification in chipinfo file "*" at line *
(Driver)
This attribute can only be defined once but has been defined more than once for this
chip.
(1020) unknown attribute "*" in chipinfo file "*" at line *
(Driver)
The chip configuration file contains an attribute that is not understood by this version of
the compiler. Has the chip configuration file or the driver been replaced with an equivalent component from another version of this compiler?
(1021) syntax error reading "*" value in chipinfo file "*" at line *
(Driver)
The chip configuration file incorrectly defines the specified value for this device. If you
are modifying this file yourself, take care and refer to the comments at the beginning of
this file for a description on what type of values are expected here.
(1022) syntax error reading "*" range in chipinfo file "*" at line *
(Driver)
The chip configuration file incorrectly defines the specified range for this device. If you
are modifying this file yourself, take care and refer to the comments at the beginning of
this file for a description on what type of values are expected here.
(1024) syntax error in chipinfo file "*" at line *
(Driver)
The chip configuration file contains a syntax error at the line specified.
(1025) unknown architecture in chipinfo file "*" at line *
(Driver)
The attribute at the line indicated defines an architecture that is unknown to this compiler.
(1026) missing architecture in chipinfo file "*" at line *
(Assembler)
The chipinfo file has a device section without an ARCH values. The architecture of the
device must be specified. Contact Microchip Technical Support if the chipinfo file has
not been modified.
(1027) activation was successful
(Driver)
The compiler was successfully activated.
(1028) activation was not successful - error code (*)
(Driver)
The compiler did not activated successfully.
DS52053B-page 454
2012 Microchip Technology Inc.
Error and Warning Messages
(1029) compiler not installed correctly - error code (*)
(Driver)
This compiler has failed to find any activation information and cannot proceed to execute. The compiler may have been installed incorrectly or incompletely. The error code
quoted can help diagnose the reason for this failure. You may be asked for this failure
code if contacting Microchip for assistance with this problem.
(1030) Hexmate - Intel HEX editing utility (Build 1.%i)
(Hexmate)
Indicating the version number of the HEXMATE being executed.
(1031) USAGE: * [input1.HEX] [input2.HEX]... [inputN.HEX] [options]
(Hexmate)
The suggested usage of HEXMATE.
(1032) use –HELP= for usage of these command line options
(Hexmate)
More detailed information is available for a specific option by passing that option to the
HELP option.
(1033) available command-line options:
(Hexmate)
This is a simple heading that appears before the list of available options for this
application.
(1034) type "*" for available options
(Hexmate)
It looks like you need help. This advisory suggests how to get more information about
the options available to this application or the usage of these options.
(1035) bad argument count (*)
(Parser)
The number of arguments to a function is unreasonable. This is an internal compiler
error. Contact Microchip Technical Support with details.
(1036) bad "*" optional header length (0x* expected)
(Cromwell)
The length of the optional header in this COFF file was of an incorrect length.
(1037) short read on *
(Cromwell)
When reading the type of data indicated in this message, it terminated before reaching
its specified length.
(1038) string table length too short
(Cromwell)
The specified length of the COFF string table is less than the minimum.
(1039) inconsistent symbol count
(Cromwell)
The number of symbols in the symbol table has exceeded the number indicated in the
COFF header.
(1040) bad checksum: record 0x*, checksum 0x*
(Cromwell)
A record of the type specified failed to match its own checksum value.
(1041) short record
(Cromwell)
While reading a file, one of the file’s records ended short of its specified length.
(1042) unknown * record type 0x*
(Cromwell)
The type indicator of this record did not match any valid types for this file format.
(1043) unknown optional header
(Cromwell)
When reading this Microchip COFF file, the optional header within the file header was
of an incorrect length.
2012 Microchip Technology Inc.
DS52053B-page 455
MPLAB® XC8 C Compiler User’s Guide
(1044) end of file encountered
(Cromwell, Linker)
The end of the file was found while more data was expected. Has this input file been
truncated?
(1045) short read on block of * bytes
(Cromwell)
A while reading a block of byte data from a UBROF record, the block ended before the
expected length.
(1046) short string read
(Cromwell)
A while reading a string from a UBROF record, the string ended before the specified
length.
(1047) bad type byte for UBROF file
(Cromwell)
This UBROF file did not begin with the correct record.
(1048) bad time/date stamp
(Cromwell)
This UBROF file has a bad time/date stamp.
(1049) wrong CRC on 0x* bytes; should be *
(Cromwell)
An end record has a mismatching CRC value in this UBROF file.
(1050) bad date in 0x52 record
(Cromwell)
A debug record has a bad date component in this UBROF file.
(1051) bad date in 0x01 record
(Cromwell)
A start of program record or segment record has a bad date component in this UBROF
file.
(1052) unknown record type
(Cromwell)
A record type could not be determined when reading this UBROF file.
(1053) additional RAM ranges larger than bank size
(Driver)
A block of additional RAM being requested exceeds the size of a bank. Try breaking
the block into multiple ranges that do not cross bank boundaries.
(1054) additional RAM range out of bounds
(Driver)
The RAM memory range as defined through custom RAM configuration is out of range.
(1055) RAM range out of bounds (*)
(Driver)
The RAM memory range as defined in the chip configuration file or through custom
configuration is out of range.
(1056) unknown chip architecture
(Driver)
The compiler is attempting to compile for a device of an architecture that is either
unsupported or disabled.
(1057) fast double option only available on 17 series processors
(Driver)
The fast double library cannot be selected for this device. These routines are only available for PIC17 devices.
(1058) assertion
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
DS52053B-page 456
2012 Microchip Technology Inc.
Error and Warning Messages
(1059) rewrite loop
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(1081) static initialization of persistent variable "*"
(Parser, Code Generator)
A persistent variable has been assigned an initial value. This is somewhat contradictory
as the initial value will be assigned to the variable during execution of the compiler’s
startup code; however, the persistent qualifier requests that this variable shall be
unchanged by the compiler’s startup code.
(1082) size of initialized array element is zero
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(1088) function pointer "*" is used but never assigned a value
(Code Generator)
A function call involving a function pointer was made, but the pointer was never
assigned a target address, for example:
void (*fp)(int);
fp(23);
/* oops -- what function does fp point to? */
(1089) recursive function call to "*"
(Code Generator)
A recursive call to the specified function has been found. The call may be direct or indirect (using function pointers) and may be either a function calling itself, or calling
another function whose call graph includes the function under consideration.
(1090) variable "*" is not used
(Code Generator)
This variable is declared but has not been used by the program. Consider removing it
from the program.
(1091) main function "*" not defined
(Code Generator)
The main function has not been defined. Every C program must have a function called
main.
(1094) bad derived type
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(1095) bad call to typeSub()
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(1096) type should be unqualified
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(1097) unknown type string "*"
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(1098) conflicting declarations for variable "*" (*:*)
(Parser, Code Generator)
Differing type information has been detected in the declarations for a variable, or
between a declaration and the definition of a variable, for example:
extern long int test;
int test;
/* oops -- which is right? int or long int ? */
(1104) unqualified error
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
2012 Microchip Technology Inc.
DS52053B-page 457
MPLAB® XC8 C Compiler User’s Guide
(1118) bad string "*" in getexpr(J)
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(1119) bad string "*" in getexpr(LRN)
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(1121) expression error
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(1137) match() error: *
(Code Generator)
This is an internal compiler error. Contact Microchip Technical Support with details.
(1157) W register must be W9
(Assembler)
The working register required here has to be W9, but an other working register was
selected.
(1159) W register must be W11
(Assembler)
The working register required here has to be W11, but an other working register was
selected.
(1178) the "*" option has been removed and has no effect
(Driver)
This option no longer exists in this version of the compiler and has been ignored. Use
the compiler’s –help option or refer to the manual to find a replacement option.
(1179) interrupt level for function "*" may not exceed *
(Code Generator)
The interrupt level for the function specified is too high. Each interrupt function is
assigned a unique interrupt level. This level is considered when analyzing the call
graph and reentrantly called functions. If using the interrupt_level pragma, check
the value specified.
(1180) directory "*" does not exist
(Driver)
The directory specified in the setup option does not exist. Create the directory and try
again.
(1182) near variables must be global or static
(Code Generator)
A variable qualified as near must also be qualified with static or made global. An auto
variable cannot be qualified as near.
(1183) invalid version number
(Activation)
During activation, no matching version number was found on the Microchip activation
server database for the serial number specified.
(1184) activation limit reached
(Activation)
The number of activations of the serial number specified has exceeded the maximum
number allowed for the license.
(1185) invalid serial number
(Activation)
During activation, no matching serial number was found on the Microchip activation
server database.
(1186) license has expired
(Driver)
The time-limited license for this compiler has expired.
DS52053B-page 458
2012 Microchip Technology Inc.
Error and Warning Messages
(1187) invalid activation request (
Driver)
The compiler has not been correctly activated.
(1188) network error *
(Activation)
The compiler activation software was unable to connect to the Microchip activation
server via the network.
(1190) FAE license only - not for use in commercial applications
(Driver)
Indicates that this compiler has been activated with an FAE license. This license does
not permit the product to be used for the development of commercial applications.
(1191) licensed for educational use only
(Driver)
Indicates that this compiler has been activated with an education license. The educational license is only available to educational facilities and does not permit the product
to be used for the development of commercial applications.
(1192) licensed for evaluation purposes only
(Driver)
Indicates that this compiler has been activated with an evaluation license.
(1193) this license will expire on *
(Driver)
The compiler has been installed as a time-limited trial. This trial will end on the date
specified.
(1195) invalid syntax for "*" option
(Driver)
A command line option that accepts additional parameters was given inappropriate
data or insufficient data. For example, an option may expect two parameters with both
being integers. Passing a string as one of these parameters or supplying only one
parameter could result in this error.
(1198) too many "*" specifications; * maximum
(Hexmate)
This option has been specified too many times. If possible, try performing these operations over several command lines.
(1199) compiler has not been activated
(Driver)
The trial period for this compiler has expired. The compiler is now inoperable until activated with a valid serial number. Contact Microchip to purchase this software and
obtain a serial number.
(1200) Found %0*lXh at address *h
(Hexmate)
The code sequence specified in a -FIND option has been found at this address.
(1201) all FIND/REPLACE code specifications must be of equal width
(Hexmate)
All find, replace and mask attributes in this option must be of the same byte width.
Check the parameters supplied to this option. For example, finding 1234h (2 bytes)
masked with FFh (1 byte) results in an error; but, masking with 00FFh (2 bytes) works.
(1202) unknown format requested in -FORMAT: *
(Hexmate)
An unknown or unsupported INHX format has been requested. Refer to documentation
for supported INHX formats.
2012 Microchip Technology Inc.
DS52053B-page 459
MPLAB® XC8 C Compiler User’s Guide
(1203) unpaired nibble in * value will be truncated
(Hexmate)
Data to this option was not entered as whole bytes. Perhaps the data was incomplete
or a leading zero was omitted. For example, the value Fh contains only four bits of significant data and is not a whole byte. The value 0Fh contains eight bits of significant
data and is a whole byte.
(1204) * value must be between 1 and * bytes long
(Hexmate)
An illegal length of data was given to this option. The value provided to this option
exceeds the maximum or minimum bounds required by this option.
(1205) using the configuration file *; you may override this with the environment variable HTC_XML
(Driver)
This is the compiler configuration file selected during compiler setup. This can be
changed via the HTC_XML environment variable. This file is used to determine where
the compiler has been installed.
(1207) some of the command line options you are using are now obsolete
(Driver)
Some of the command line options passed to the driver have now been discontinued
in this version of the compiler; however, during a grace period these old options will still
be processed by the driver.
(1208) use –help option or refer to the user manual for option details
(Driver)
An obsolete option was detected. Use –help or refer to the manual to find a replacement option that will not result in this advisory message.
(1209) An old MPLAB tool suite plug-in was detected.
(Driver)
The options passed to the driver resemble those that the Microchip MPLAB IDE would
pass to a previous version of this compiler. Some of these options are now obsolete;
however, they were still interpreted. It is recommended that you install an updated
Microchip options plug-in for the MPLAB IDE.
(1210) Visit the Microchip website (www.microchip.com) for a possible upgrade
(Driver)
Visit our website to see if an upgrade is available to address the issue(s) listed in the
previous compiler message. Navigate to the MPLAB XC8 C Compiler page and look
for a version upgrade downloadable file. If your version is current, contact Microchip
Technical Support for further information.
(1212) Found * (%0*lXh) at address *h
(Hexmate)
The code sequence specified in a -FIND option has been found at this address.
(1213) duplicate ARCH for * in chipinfo file at line *
(Assembler, Driver)
The chipinfo file has a device section with multiple ARCH values. Only one ARCH value
is allowed. If you have not manually edited the chip info file, contact Microchip Technical
Support with details.
(1218) can’t create cross reference file *
(Assembler)
The assembler attempted to create a cross reference file; but, it could not be created.
Check that the file’s path name is correct.
(1228) unable to locate installation directory
(Driver)
The compiler cannot determine the directory where it has been installed.
DS52053B-page 460
2012 Microchip Technology Inc.
Error and Warning Messages
(1230) dereferencing uninitialized pointer "*"
(Code Generator)
A pointer that has not yet been assigned a value has been dereferenced. This can
result in erroneous behavior at runtime.
(1235) unknown keyword *
(Driver)
The token contained in the USB descriptor file was not recognized.
(1236) invalid argument to *: *
(Driver)
An option that can take additional parameters was given an invalid parameter value.
Check the usage of the option or the syntax or range of the expected parameter.
(1237) endpoint 0 is pre-defined
(Driver)
An attempt has been made to define endpoint 0 in a USB file. This channel c
(1238) FNALIGN failure on * (
Linker)
Two functions have their auto/parameter blocks aligned using the FNALIGN directive,
but one function calls the other, which implies that must not be aligned. This will occur
if a function pointer is assigned the address of each function, but one function calls the
other. For example:
int one(int a) { return a; }
int two(int a) { return two(a)+2; } /* ! */
int (*ip)(int);
ip = one;
ip(23);
ip = two;
/* ip references one and two; two calls one */
ip(67);
(1239) pointer * has no valid targets
(Code Generator)
A function call involving a function pointer was made, but the pointer was never
assigned a target address, for example:
void (*fp)(int);
fp(23);
/* oops -- what function does fp point to? */
(1240) unknown checksum algorithm type (%i)
(Driver)
The error file specified after the -Efile or -E+file options could not be opened.
Check to ensure that the file or directory is valid and that has read only access.
(1241) bad start address in *
(Driver)
The start of range address for the --CHECKSUM option could not be read. This value
must be a hexadecimal number.
(1242) bad end address in *
(Driver)
The end of range address for the --CHECKSUM option could not be read. This value
must be a hexadecimal number.
(1243) bad destination address in *
(Driver)
The destination address for the --CHECKSUM option could not be read. This value must
be a hexadecimal number.
(1245) value greater than zero required for *
(Hexmate)
The align operand to the HEXMATE -FIND option must be positive.
(1246) no RAM defined for variable placement
(Code Generator)
No memory has been specified to cover the banked RAM memory.
2012 Microchip Technology Inc.
DS52053B-page 461
MPLAB® XC8 C Compiler User’s Guide
(1247) no access RAM defined for variable placement
(Code Generator)
No memory has been specified to cover the access bank memory.
(1248) symbol (*) encountered with undefined type size
(Code Generator)
The code generator was asked to position a variable, but the size of the variable is not
known. This is an internal compiler error. Contact Microchip Technical Support with
details.
MESSAGES 1250-1499
(1250) could not find space (* byte*) for variable *
(Code Generator)
The code generator could not find space in the banked RAM for the variable specified.
(1253) could not find space (* byte*) for auto/param block
(Code Generator)
The code generator could not find space in RAM for the psect that holds auto and
parameter variables.
(1254) could not find space (* byte*) for data block
(Code Generator)
The code generator could not find space in RAM for the data psect that holds initialized
variables.
(1255) conflicting paths for output directory
(Driver)
The compiler has been given contradictory paths for the output directory via any of the
-O or --OUTDIR options, for example:
--outdir=../../
-o../main.HEX
(1256) undefined symbol "*" treated as HEX constant
(Assembler)
A token which could either be interpreted as a symbol or a hexadecimal value does not
match any previously defined symbol and so will be interpreted as the latter. Use a
leading zero to avoid the ambiguity, or use an alternate radix specifier such as 0x. For
example:
MOV
a, F7h
; is this the symbol F7h, or the HEX number 0xF7?
(1257) local variable "*" is used but never given a value
(Code Generator)
An auto variable has been defined and used in an expression, but it has not been
assigned a value in the C code before its first use. Auto variables are not cleared on
startup and their initial value is undefined. For example:
void main(void) {
double src, out;
out = sin(src);
/* oops -- what value was in src? */
(1258) possible stack overflow when calling function "*"
(Code Generator)
The call tree analysis by the code generator indicates that the hardware stack may
overflow. This should be treated as a guide only. Interrupts, the assembler optimizer
and the program structure may affect the stack usage. The stack usage is based on the
C program and does not include any call tree derived from assembly code.
(1259) can’t optimize for both speed and space
(Driver)
The driver has been given contradictory options of compile for speed and compile for
space, for example:
--opt=speed,space
DS52053B-page 462
2012 Microchip Technology Inc.
Error and Warning Messages
(1260) macro "*" redefined
(Assembler)
More than one definition for a macro with the same name has been encountered, for
example:
MACRO fin
ret
ENDM
MACRO fin
reti
ENDM
; oops -- was this meant to be a different macro?
(1261) string constant required
(Assembler)
A string argument is required with the DS or DSU directive, for example:
DS ONE
; oops -- did you mean DS "ONE"?
(1262) object "*" lies outside available * space
(Code Generator)
An absolute variable was positioned at a memory location which is not within the memory defined for the target device, for example:
int data @ 0x800
/* oops -- is this the correct address? */
(1264) unsafe pointer conversion
(Code Generator)
A pointer to one kind of structure has been converted to another kind of structure and
the structures do not have a similar definition, for example:
struct ONE
unsigned
long b;
} one;
struct TWO
unsigned
unsigned
} two;
struct ONE
oneptr = &
{
a;
/* ! */
{
a;
b;
/* ! */
* oneptr;
two;
/* oops -was ONE meant to be same struct as TWO? */
(1267) fixup overflow referencing * into * bytes at 0x*
(Linker)
See the following error message (477) for more information.
(1268) fixup overflow storing 0x* in * bytes at *
(Linker)
See the following error message (477) for more information.
(1273) Omniscient Code Generation not available in Free mode
(Driver)
This message advises that advanced features of the compiler are not be enabled in this
Free mode compiler.
(1275) only functions may be qualified "*"
(Parser)
A qualifier which only makes sense when used in a function definition has been used
with a variable definition.
interrupt int dacResult; /* oops -the interrupt qualifier can only be used with functions */
(1276) buffer overflow in DWARF location list
(Cromwell)
A buffer associated with the ELF/DWARF debug file has overflowed. Contact Microchip
Technical Support with details.
2012 Microchip Technology Inc.
DS52053B-page 463
MPLAB® XC8 C Compiler User’s Guide
(1278) omitting "*" which does not have a location
(Cromwell)
A variable has no storage location listed and will be omitted from the debug output.
Contact Microchip Technical Support with details.
(1284) malformed mapfile while generating summary: CLASS expected but not found
(Driver)
The map file being read to produce a memory summary is malformed. Either the file
has been edited or corrupted, or this is a compiler error – contact Microchip Technical
Support with details.
(1285) malformed mapfile while generating summary: no name at position *
(Driver)
The map file being read to produce a memory summary is malformed. Either the file
has been edited or corrupted, or this is a compiler error – contact Microchip Technical
Support with details.
(1286) malformed mapfile while generating summary: no link address at position *(
Driver)
The map file being read to produce a memory summary is malformed. Either the file
has been edited or corrupted, or this is a compiler error – contact Microchip Technical
Support with details.
(1287) malformed mapfile while generating summary: no load address at position *
(Driver)
The map file being read to produce a memory summary is malformed. Either the file
has been edited or corrupted, or this is a compiler error – contact Microchip Technical
Support with details.
(1288) malformed mapfile while generating summary: no length at position *
(Driver)
The map file being read to produce a memory summary is malformed. Either the file
has been edited or corrupted, or this is a compiler error – contact Microchip Technical
Support with details.
(1289) line range limit exceeded, debugging may be affected
(Cromwell)
A C statement has produced assembly code output whose length exceeds a preset
limit. This means that debug information produced by CROMWELL may not be accurate.
This warning does not indicate any potential code failure.
(1290) buffer overflow in DWARF debugging information entry
(Cromwell)
A buffer associated with the ELF/DWARF debug file has overflowed. Contact Microchip
Technical Support with details.
(1291) bad ELF string table index
(Cromwell)
An ELF file passed to CROMWELL is malformed and cannot be used.
(1292) malformed define in .SDB file *
(Cromwell)
The named SDB file passed to CROMWELL is malformed and cannot be used.
(1293) couldn’t find type for "*" in DWARF debugging information entry
(Cromwell)
The type of symbol could not be determined from the SDB file passed to CROMWELL.
Either the file has been edited or corrupted, or this is a compiler error – contact Microchip Technical Support with details.
(1294) there is only one day left until this license expires
(Driver)
The compiler is running as a demo and will be unable to run in PRO mode after the
evaluation license has expired in less than one day’s time. After expiration, the compiler
can be operated in Free mode indefinitely, but will produce a larger output binary.
DS52053B-page 464
2012 Microchip Technology Inc.
Error and Warning Messages
(1295) there are * days left until this license will expire
(Driver)
The compiler is running as a demo and will be unable to run in PRO mode after the
evaluation license has expired in the indicated time. After expiration, the compiler can
be operated in Free mode indefinitely, but will produce a larger output binary.
(1296) source file "*" conflicts with "*"
(Driver)
The compiler has encountered more than one source file with the same basename.
This can only be the case if the files are contained in different directories. As the compiler and IDEs based the names of intermediate files on the basenames of source files,
and intermediate files are always stored in the same location, this situation is illegal.
Ensure the basename of all source files are unique.
(1297) option * not available in Free mode
(Driver)
Some options are not available when the compiler operates in Free mode. The options
disabled are typically related to how the compiler is executed, e.g., --GETOPTION and
--SETOPTION, and do not control compiler features related to code generation.
(1298) use of * outside macros is illegal
(Assembler)
Some assembler directives, e.g., EXITM, can only be used inside macro definitions.
(1299) non-standard modifier "*" - use "*" instead
(Parser)
A printf placeholder modifier has been used which is non-standard. Use the indicated modifier instead. For example, the standard hh modifier should be used in
preference to b to indicate that the value should be printed as a char type.
(1300) maximum number of program classes reached. List may be truncated
(Cromwell)
CROMWELL is passed a list of class names on the command line. If the number of number of class names passed in is too large, not all will be used and debugging information may be affected.
(1301) invalid ELF section header. Skipping
(Cromwell)
CROMWELL found an invalid section in an ELF section header. This section will be
skipped.
(1302) could not find valid ELF output extension for this device
(Cromwell)
The extension could not be for the target device family.
(1303) invalid variable location detected: * - *
(Cromwell)
A symbol location could not be determined from the SDB file.
(1304) unknown register name: "*"
(Cromwell)
The location for the indicated symbol in the SDB file was a register, but the register
name was not recognized.
(1305) inconsistent storage class for variable: "*"
(Cromwell)
The storage class for the indicated symbol in the SDB file was not recognized.
(1306) inconsistent size (* vs *) for variable: "*"
(Cromwell)
The size of the symbol indicated in the SDB file does not match the size of its type.
(1307) psect * truncated to * bytes
(Driver)
The psect representing either the stack or heap could not be made as large as
requested and will be truncated to fit the available memory space.
2012 Microchip Technology Inc.
DS52053B-page 465
MPLAB® XC8 C Compiler User’s Guide
(1308) missing/conflicting interrupts sub-option, defaulting to "*"
(Driver)
The suboptions to the --INTERRUPT option are missing or malformed, for example:
--INTERRUPTS=single,multi
Oops, did you mean single-vector or multi-vector interrupts?
(1309) ignoring invalid runtime * sub-option (*) using default
(Driver)
The indicated suboption to the --RUNTIME option is malformed, for example:
--RUNTIME=default,speed:0y1234
Oops, that should be 0x1234.
(1310) specified speed (*Hz) exceeds max operating frequency (*Hz), defaulting to *Hz
(Driver)
The frequency specified to the perform suboption to --RUNTIME option is too large
for the selected device.
--RUNTIME=default,speed:0xffffffff
Oops, that value is too large.
(1311) missing configuration setting for config word *, using default
(Driver)
The configuration settings for the indicated word have not be supplied in the source
code and a default value will be used.
(1312) conflicting runtime perform sub-option and configuration word settings, assuming *Hz
(Driver)
The configuration settings and the value specified with the perform suboption of the
--RUNTIME options conflict and a default frequency has been selected.
(1313) * sub-options ("*") ignored
(Driver)
The argument to a suboption is not required and will be ignored.
--OUTPUT=intel:8
Oops, the :8 is not required
(1314) illegal action in memory allocation
(Code Generator)
This is an internal error. Contact Microchip Technical Support with details.
(1315) undefined or empty class used to link psect *
(Linker)
The linker was asked to place a psect within the range of addresses specified by a
class, but the class was either never defined, or contains no memory ranges.
(1316) attribute "*" ignored
(Parser)
An attribute has been encountered that is valid, but which is not implemented by the
parser. It will be ignored by the parser and the attribute will have no effect. Contact
Microchip Technical Support with details.
(1317) missing argument to attribute "*"
(Parser)
An attribute has been encountered that requires an argument, but this is not present.
Contact Microchip Technical Support with details.
(1318) invalid argument to attribute "*"
(Parser)
An argument to an attribute has been encountered, but it is malformed. Contact Microchip Technical Support with details.
DS52053B-page 466
2012 Microchip Technology Inc.
Error and Warning Messages
(1319) invalid type "*" for attribute "*"
(Parser)
This indicated a bad option passed to the parser. Contact Microchip Technical Support
with details.
(1320) attribute "*" already exists
(Parser)
This indicated the same attribute option being passed to the parser more than once.
Contact Microchip Technical Support with details.
(1321) bad attribute -T option "%s"
(Parser)
The attribute option passed to the parser is malformed. Contact Microchip Technical
Support with details.
(1322) unknown qualifier "%s" given to -T
(Parser)
The qualifier specified in an attribute option is not known. Contact Microchip Technical
Support with details.
(1323) attribute expected
(Parser)
The __attribute__ directive was used but did not specify an attribute type.
int rv (int a) __attribute__(())
/* oops -- what is the attribute? */
(1324) qualifier "*" ignored
(Parser)
Some qualifiers are valid, but may not be implemented on some compilers or target
devices. This warning indicates that the qualifier will be ignored.
(1325) no such CP* register: ($*), select (*)
(Code Generator)
A variable has been qualifier as cp0, but no corresponding co-device register exists at
the address specified with the variable.
cp0 volatile unsigned int mycpvar @ 0x7000;
/* oops -did you mean 0x700, try... */
cp0 volatile unsigned int mycpvar @ __REGADDR(7, 0);
(1326) "*" qualified variable (*) missing address
(Code Generator)
A variable has been qualifier as cp0, but the co-device register address was not specified.
cp0 volatile unsigned int mycpvar;
/* oops -- what address ? */
(1327) interrupt function "*" redefined by "*"
(Code Generator)
An interrupt function has been written that is linked to a vector location that already has
an interrupt function lined to it.
void interrupt timer1_isr(void) @ TIMER_1_VCTR { ... }
void interrupt timer2_isr(void) @ TIMER_1_VCTR { ... }
/* oops -did you mean that to be TIMER_2_VCTR */
(1328) coprocessor * registers can’t be accessed from * code
(Code Generator)
Code in the indicated instruction set has illegally attempted to access the coprocessor
registers. Ensure the correct instruction set is used to encode the enclosing function.
(1329) can only modify RAM type interrupt vectors
(Code Generator)
The SETVECTOR() macro has been used to attempt to change the interrupt vector
table, but this table is in ROM and cannot be changed at runtime.
2012 Microchip Technology Inc.
DS52053B-page 467
MPLAB® XC8 C Compiler User’s Guide
(1330) only functions or function pointers may have an instruction set architecture qualifier (Code
Generator)
An instruction set qualifier has been used with something that does not represent executable code.
mips16e int input;
/* oops -- you can’t qualify a variable with an
instruction set type */
(1331) interrupt functions may not be qualified "*"
(Code Generator)
A illegal function qualifier has been used with an interrupt function.
mips16e void interrupt tisr(void) @ CORE_TIMER_VCTR;
/* oops -you can’t use mips16e with interrupt functions */
(1332) invalid qualifier (*) and type combination on "*"
(Code Generator)
Some qualified variables must have a specific type or size. A combination has been
detected that is not allowed.
volatile cp0 int mycpvar @ __REGADDR(7,0);
/* oops -you must use unsigned types with the cp0 qualifier */
(1333) can’t extend instruction
(Assembler)
An attempt was made to extend a MIPS16E instruction where the instruction is
non-extensible. This is an internal error. Contact Microchip Technical Support with
details.
(1334) invalid * register operand
(Assembler)
An illegal register was used with an assembly instruction. Either this is an internal error
or caused by hand-written assembly code.
psect my_text,isa=mips16e,reloc=4
move t0,t1 /* oops -- these registers can’t be used in the
16-bit instruction set */
(1335) instruction "*" is deprecated
(Assembler)
An assembly instruction was used that is deprecated.
beql t0,t1,12
/* oops -- this instruction is no longer supported */
(1336) a psect may belong to only one ISA
(Assembler)
Psects that have a flag that defines the allowed instruction set architecture. A psect has
been defined whose ISA flag conflicts with that of another definition for the same psect.
mytext,global,isa=mips32r2,reloc=4,delta=1
mytext,global,isa=mips16e,reloc=4,delta=1
/* oops -is this the right psect name or the wrong ISA value */
(1337) instruction/macro "*" is not part of psect ISA
(Assembler)
An instruction from one instruction set architecture has been found in a psect whose
ISA flag specifies a different architecture type.
psect my_text,isa=mips16e,reloc=4
mtc0 t0,t1
/* oops -- this is a 32-bit instruction */
(1338) operand must be a * bit value
(Assembler)
The constant operand to an instruction is too large to fit in the instruction field width.
psect my_text,isa=mips32r2,reloc=4
li t0,0x123456789 /* oops -- this constant is too large */
DS52053B-page 468
2012 Microchip Technology Inc.
Error and Warning Messages
(1339) operand must be a * bit * value
(Assembler)
The constant operand to an instruction is too large to fit in the instruction field width and
must have the indicated type.
addiu
a3, a3, 0x123456
/* oops -the constant operand to this MIPS16E instruction is too large */
(1340) operand must be >= * and 0 and 0x* (*** */0x*)
(Linker)
See also message (477). This form of the message precalculates the address of the
offending instruction taking into account the delta value of the psect which contains the
instruction.
(1357) fixup overflow storing 0x* in * byte* at 0x*/0x* -> 0x* (*** */0x*)
(Linker)
See also message (477). This form of the message precalculates the address of the
offending instruction taking into account the delta value of the psect which contains the
instruction.
(1358) no space for * temps (*)
(Code Generator)
The code generator was unable to find a space large enough to hold the temporary
variables (scratch variables) for this program.
(1359) no space for * parameters
(Code Generator)
The code generator was unable to find a space large enough to hold the parameter
variables for a particular function.
(1360) no space for auto/param *
(Code Generator)
The code generator was unable to find a space large enough to hold the auto variables
for a particular function. Some parameters passed in registers may need to be
allocated space in this auto area as well.
(1361) syntax error in configuration argument
(Parser)
The argument to #pragma config was malformed.
#pragma config WDT
(1362) configuration setting *=* redefined
/* oops -- is WDT on or off? */
(Code Generator)
The same config pragma setting have been issued more than once with different values.
#pragma config WDT=OFF
#pragma config WDT=ON
DS52053B-page 470
/* oops -- is WDT on or off? */
2012 Microchip Technology Inc.
Error and Warning Messages
(1363) unknown configuration setting (* = *) used
(Driver)
The configuration value and setting is not known for the target device.
#pragma config WDR=ON
/* oops -- did you mean WDT? */
(1364) can’t open configuration registers data file *
(Driver)
The file containing value configuration settings could not be found.
(1365) missing argument to pragma "varlocate"
(Parser)
The argument to #pragma varlocate was malformed.
#pragma varlocate
/* oops -- what do you want to locate & where? */
(1366) syntax error in pragma "varlocate"
(Parser)
The argument to #pragma varlocate was malformed.
#pragma varlocate fred
/* oops -- which bank for fred? */
(1367) end of file in _asm
(Parser)
An end-of-file marker was encountered inside a _asm _endasm block.
(1368) assembler message: *
(Assembler)
Displayed is an assembler advisory message produced by the MESSG directive contained in the assembler source.
(1369) can’t open proc file *
(Driver)
The proc file for the selected device could not be opened.
(1370) peripheral library support is not available for the *
(Driver)
The peripheral library is not available for the selected device.
(1371) float type can’t be bigger than double type; double has been changed to * bits
(Driver)
Use of the --float and --double options has result in the size of the double type
being smaller than that of the float type. This is not permitted by the C Standard. The
double type size has been increased to be that indicated.
(1372) interrupt level cannot be greater than *
(Code Generator)
The specific interrupt_level is too high for the device selected.
#pragma interrupt_level 4
// oops - there aren't that many interrupts on this device
(1374) the compiler feature "*" is no longer supported, *
(Driver)
The feature indicated is no longer supported by the compiler.
(1375) multiple interrupt functions (* and *) defined for device with only one interrupt vector
(Code Generator)
The named functions have both been qualified interrupt, but the target device only supports one interrupt vector and hence one interrupt function.
interrupt void isr_lo(void) {
// ...
}
interrupt void isr_hi(void) {
// ...
}
2012 Microchip Technology Inc.
// oops, can’t define two ISRs
DS52053B-page 471
MPLAB® XC8 C Compiler User’s Guide
(1376) initial value (*) too large for bitfield width (*)
(Code Generator)
A structure with bit-fields has been defined an initialized with values. The value indicated it too large to fit in the corresponding bit-field width.
struct {
unsigned flag :1;
unsigned mode :3;
} foobar = { 1, 100 };
// oops, 100 is too large for a 3 bit object
(1377) no suitable strategy for this switch
(Code Generator)
The compiler was unable to determine the switch strategy to use to encode a C switch
statement based on the code and your selection using the #pragma switch directive.
You may need to choose a different strategy.
(1378) syntax error in pragma "*"
(Parser)
The arguments to the indicated pragma are not valid.
#pragma addrqual ingore
// oops -- did you mean ignore?
(1379) no suitable strategy for this switch
(Code Generator)
The compiler encodes switch() statements according to one of a number of strategies. The specific number and values of the case values, and the switch expression,
as well as the switch pragma determine the strategy chosen. This error indicates that
no strategy was available to encode the switch() statement. Contact Microchip support with program details.
(1380) unable to use switch strategy "*"
(Code Generator)
The compiler encodes switch() statements according to one of a number of strategies. The specific number and values of the case values, and the switch expression,
as well as the switch pragma determine the strategy chosen. This error indicates that
the strategy which as requested cannot be used to encode the switch() statement.
Contact Microchip support with program details.
(1381) invalid case label range
(Parser)
The values supplied for the case range are not correct. They must form an ascending
range and integer constants.
case 0 ... -2:
// oops -- do you mean -2 ... 0
?
(1385) * "*" is deprecated (declared at *:*)
(Parser)
Code is using a variable or function that was marked as being deprecated using an
attribute.
char __attribute__((deprecated)) foobar;
foobar = 9;
// oops -- this variable is near end-of-life
(1386) unable to determine the semantics of the configuration setting "*" for register "*"
(Parser, Code Generator)
The numerical value supplied to a configuration bit setting has no direct association
setting specified in the data sheet. The compiler will attempt to honor your request, but
check your device data sheet.
#pragma config OSC=11
// oops -- there is no direct association for that value on an 18F2520
// either use OSC=3 or OSC=RC
DS52053B-page 472
2012 Microchip Technology Inc.
Error and Warning Messages
(1387) inline delay argument must be constant
(Code Generator)
The __delay inline function can only take a constant expression as its argument.
int delay_val = 99;
__delay(delay_val);
// oops, argument must be a constant expression
(1388) configuration setting/register of "*" with 0x* will be truncated by 0x*
(Parser, Code Generator)
A configuration bit has been programmed with a value that is either too large for the
setting, or not one of the prescribed values.
#pragma config WDTPS=138
// oops -- do you mean 128?
(1389) attempt to reprogram configuration * "*" with * (is *)
(Parser, Code Generator)
A configuration bit already programmed has been programmed again with a conflicting
setting to the original.
#pragma config WDT=ON
#pragma config WDT=OFF
// oops -- watchdog on or off?
(1390) identifier specifies insignificant characters beyond maximum identifier length
(Parser)
An identifier has been used that is so long that it exceeds the set identifier length. This
may mean that long identifiers may not be correctly identified and the code will fail. The
maximum identifier length can be adjusted using the -N option.
int theValueOfThePortAfterTheModeBitsHaveBeenSet;
// oops, make your symbol shorter or increase the maximum
// identifier length
(1391) constant object size of * exceeds the maximum of * for this chip
(Code Generator)
The const object defined is too large for the target device.
const int array[200] = { ... };
// oops -- not on a Baseline part!
(1392) function "*" is called indirectly from both mainline and interrupt code
(Code Generator)
A function has been called by main-line (non-interrupt) and interrupt code. If this warning is issued, it highlights that such code currently violates a compiler limitation for the
selected device.
(1393) possible hardware stack overflow detected, estimated stack depth: *
(Code Generator)
The compiler has detected that the call graph for a program may be using more stack
space that allocated on the target device. If this is the case, the code may fail. The compiler can only make assumption regarding the stack usage when interrupts are involved
and these lead to a worst-case estimate of stack usage. Confirm the function call nesting if this warning is issued.
(1394) attempting to create memory range ( * - * ) larger than page size, *
(Driver)
The compiler driver has detected that the memory settings include a program memory
“page” that is larger than the page size for the device. This would mostly likely be the
case if the --ROM option is used to change the default memory settings. Consult you
device data sheet to determine the page size of the device you are using and ensure
that any contiguous memory range you specify using the --ROM option has a boundary
that corresponds to the device page boundaries.
--ROM=100-1fff
The above may need to be paged. If the page size is 800h, the above could specified as
--ROM=100-7ff,800-fff,1000-17ff,1800-1fff
2012 Microchip Technology Inc.
DS52053B-page 473
MPLAB® XC8 C Compiler User’s Guide
(1395) notable code sequence candidate suitable for compiler validation suite detected (*)
(Code Generator)
The compiler has in-built checks that can determine if combinations of internal code
templates have been encountered. Where unique combinations are uncovered when
compiling code, this message is issued. This message is not an error or warning, and
its presence does not indicate possible code failure, but if you are willing to participate,
the code you are compiling can be sent to Support to assist with the compiler testing
process.
(1396) "*" positioned in the * memory region (0x* - 0x*) reserved by the compiler (Code Generator)
Some memory regions are reserved for use by the compiler. These regions are not normally used to allocate variables defined in your code. However, by making variables
absolute, it is possible to place variables in these regions and avoid errors that would
normally be issued by the linker. (Absolute variables can be placed at any location,
even on top of other objects.) This warning from the code generator indicates that an
absolute has been detected that will be located at memory that the compiler will be
reserving. You must locate the absolute variable at a different location. This message
will commonly be issued when placing variables in the common memory space.
char shared @ 0x7;
// oops, this memory is required by the compiler
(1397) unable to implement non-stack call to "*"; possible hardware stack overflow
(Code Generator)
The compiler must encode a C function call without using a CALL assembly instruction
and the hardware stack (i.e., use a lookup table), but is unable to. A call instruction
might be required if the function is called indirectly via a pointer, but if the hardware
stack is already full, an additional call will cause a stack overflow.
(1401) eeprom qualified variables can’t be accessed from both interrupt and mainline code
(Code Generator)
All eeprom variables are accessed via routines which are not reentrant. Code might fail
if an attempt is made to access eeprom-qualified variables from interrupt and main-line
code. Avoid accessing eeprom variables in interrupt functions.
(1402) a pointer to eeprom can’t also point to other data types
(Code Generator)
A pointer cannot have targets in both the eeprom space and ordinary data space.
(1403) pragma "*" ignored
(Parser)
The pragma you have specified has no effect and will be ignored by the compiler. This
message may only be issued in C18 compatibility mode.
#pragma varlocate "mySection" fred
// oops -- not accepted
(1404) unsupported: *
(Parser)
The unsupported __attribute__ has been used to indicate that some code
feature is not supported.
The message printed will indicate the feature that is not supported and which should
be avoided.
(1405) storage class specifier "*" ignored
(Parser)
The storage class you have specified is not required and will be ignored by the compiler. This message may only be issued in C18 compatibility mode.
int procInput(auto int inValue)
{ ...
DS52053B-page 474
// oops -- no need for auto
2012 Microchip Technology Inc.
Error and Warning Messages
(1406) auto eeprom variables are not supported
(Code Generator)
Variables qualified as eeprom cannot be auto. You can define static local objects
qualified as eeprom, if required.
void main(void) {
eeprom int mode;
// oops -- make this static or global
(1407) bit eeprom variables are not supported
(Code Generator)
Variables qualified as eeprom cannot have type bit.
eeprom bit myEEbit;
// oops -- you can’t define bits in EEPROM
(1408) ignoring initialization of far variables
(Code Generator)
Variables qualified as far cannot be assigned an initial value. Assign the value later in
the code.
far int chan = 0x1234; // oops -- you can’t assign a value here
(1409) warning number used with pragma "warning" is invalid
(Parser)
The message number used with the warning pragma is below zero or larger than the
highest message number available.
#pragma warning disable 1316 13350
// oops -- maybe number 1335?
(1410) can’t assign the result of an invalid function pointer
(Code Generator)
The compiler will allow some functions to be called via a constant cast to be a function
pointer, but not all. The address specified is not valid for this device.
foobar += ((int (*)(int))0x0)(77);
// oops -- you can’t call a function with a NULL pointer
(1411) Additional ROM range out of bounds
(Driver)
Program memory specified with the --ROM option is outside of the on-chip, or external,
memory range supported by this device.
--ROM=default,+2000-2ffff
Oops -- memory too high, should that be 2fff?
(1412) missing argument to pragma "warning disable"
(Parser)
Following the #pragma warning disable should be a comma-separated list of message numbers to disable.
#pragma warning disable
// oops -- what messages are to be disabled?
Try something like the following.
#pragma warning disable 1362
(1413) "*" is positioned at address 0x0 and has had its address taken; pointer comparisons may be
invalid
(Code Generator)
An absolute object placed at address 0 has had its address taken. By definition, this is
a NULL pointer and code which checks for NULL (i.e., checks to see if the address is
valid) may fail.
int foobar @ 0x00;
int * ip;
void
main(void)
{
ip = &foobar;
2012 Microchip Technology Inc.
// oops -- 0 is not a valid address
DS52053B-page 475
MPLAB® XC8 C Compiler User’s Guide
(1414) option * is defunct and has no effect
(Driver)
The option used is now longer supported. It will be ignored.
xc8 --chip=18f452 --cp=24 main.c
Oops -- the --cp option is no longer required.
(1415) argument to "merge" psect flag must be 0 or 1
(Assembler)
This psect flag must be assigned a 0 or 1.
PSECT myTxt,class=CODE,merge=true
; oops -- I think you mean merge=1
(1416) psect flag "merge" redefined
(Assembler)
A psect with a name seen before specifies a different merge flag value to that previously seen.
psect
; and
psect
Oops,
mytext,class=CODE,merge=1
later
mytext,class=CODE,merge=0
can mytext be merged or not?
(1417) argument to "split" psect flag must be 0 or 1
(Assembler)
This psect flag must be assigned a 0 or 1.
psect mytext,class=CODE,split=5
Oops, the split flag argument must be 0 or 1.
(1418) Attempt to read "control" qualified object which is Write-Only
(Code Generator)
An attempt was made to read a write-only register.
state = OPTION;
// oops -- you cannot read this register
(1419) using the configuration file *; you may override this with the environment variable XC_XML
(Driver)
This is the compiler configuration file selected during compiler setup. This can be
changed via the XC_XML environment variable. This file is used to determine where the
compiler has been installed. See also message 1205.
(1420) ignoring suboption "*"
(Driver)
The suboption you have specified is not valid in this implementation and will be ignored.
--RUNTIME=default,+ramtest
oops -- what is ramtest?
(1421) the qualifier __xdata is not supported by this architecture
(Parser)
The qualifier you have specified is not valid in this implementation and will be ignored.
__xdata int coeff[2];
// that has no meaning for this target
(1422) the qualifier __ydata is not supported by this architecture
(Parser)
The qualifier you have specified is not valid in this implementation and will be ignored.
__ydata int coeff[2];
// that has no meaning for this target
(1423) case ranges are not supported
(Driver)
The use of GCC-style numerical ranges in case values does not conform to the CCI
Standard. Use individual case labels and values to conform.
switch(input) {
case 0 ... 5:
low();
DS52053B-page 476
// oops -- ranges of values are not supported
2012 Microchip Technology Inc.
Error and Warning Messages
(1424) short long integer types are not supported
(Parser)
The use of the short long type does not conform to the CCI Standard. Use the corresponding long type instead.
short long typeMod;
// oops -- not a valid type for CCI
(1425) __pack qualifier only applies to structures and structure members
(Parser)
The qualifier you have specified only makes sense when used with structures or structure members. It will be ignored.
__pack int c;
an int
// oops -- there aren’t inter-member spaces to pack in
(1426) 24-bit floating point types are not supported; * have been changed to 32-bits
(Driver)
Floating-point types must be 32-bits wide to conform to the CCI Standard. These types
will be compiled as 32-bit wide quantities.
--DOUBLE=24
oops -- you cannot set this double size
(1427) machine-dependent path specified in name of included file, use -I instead
(Preprocessor)
Header files specifications must not contain directory separators to conform to the CCI
Standard.
#inlcude
// oops -- do not indicate directories here
Remove the path information and use the -I option to indicate this, for example.
#include
and issue the -Ilcd option.
(1429) attribute "*" is not understood by the compiler; this attribute will be ignored
(Parser)
The indicated attribute you have used is not valid with this implementation. It will be
ignored.
int x __attribute__ ((deprecate)) = 0;
oops -- did you mean deprecated?
(1430) section redefined from "*" to "*"
(Parser)
You have attempted to place an object in more than one section.
int __section("foo") __section("bar") myvar;
should it be in?
// oops -- which section
(1431) only variable and function definitions at file-scope may be located using __section()(Parser)
You may not attempt to locate local objects using the __section() specifier.
int main(void) {
int __section("myData") counter;
section for autos
(1432) "*" is not a valid section name
// oops -- you cannot specify a
(Parser)
The section name specified with __section() is not a valid section name. The section
name must conform to normal C identifier rules.
int __section("28data") counter;
with digits
2012 Microchip Technology Inc.
// oops -- name cannot start
DS52053B-page 477
MPLAB® XC8 C Compiler User’s Guide
(1433) function "*" could not be inlined
(Assembler)
The specified function could not be made inline. The function will called in the usual
way.
int inline getData(int port)
{
//...
// sorry -- no luck inlining this
(1434) missing name after pragma "intrinsic"
(Parser)
The instrinsic pragma needs a function name. This pragma is not needed in most situation. If you mean to inline a function, see the inline keyword or pragma.
#pragma intrinsic
// oops -- what function is intrinsically called?
(0) delete what ?
(Libr)
The librarian requires one or more modules to be listed for deletion when using the d
key, for example:
libr d c:\ht-pic\lib\pic704-c.lib
does not indicate which modules to delete. try something like:
libr d c:\ht-pic\lib\pic704-c.lib wdiv.obj
(0) incomplete ident record
(Libr)
The IDENT record in the object file was incomplete. Contact Microchip Technical
Support with details.
(0) incomplete symbol record
(Libr)
The SYM record in the object file was incomplete. Contact Microchip Technical Support
with details.
(0) library file names should have.lib extension: *
(Libr)
Use the .lib extension when specifying a library filename.
(0) module * defines no symbols
(Libr)
No symbols were found in the module’s object file. This may be what was intended, or
it may mean that part of the code was inadvertently removed or commented.
(0) replace what ?
(Libr)
The librarian requires one or more modules to be listed for replacement when using the
r key, for example:
libr r lcd.lib
This command needs the name of a module (.obj file) after the library name.
DS52053B-page 478
2012 Microchip Technology Inc.
MPLAB® XC8 C COMPILER
USER’S GUIDE
Appendix C. Implementation-Defined Behavior
This section discusses implementation-defined behavior for this implementation of the
MPLAB XC8 C Compiler. The exact behavior of some C code can vary from compiler
to compiler, and the ANSI standard for C requires that vendors document the specifics
of implementation-defined features of the language.
The number in brackets after each item refers to the section number in the Standard to
which the item relates.
C.1
TRANSLATION (G.3.1)
C.1.1
How a diagnostic is identified (5.1.1.3)
The format of diagnostics is fully controllable by the user. By default, when compiling
on the command-line the following formats are used. Always indicated in the display is
a unique message ID number. The string (warning) is only displayed if the message
is a warning.
filename: function()
linenumber:source line
^ (ID) message (warning)
or
filename: linenumber: (ID) message (warning)
where filename is the name of the file that contains the code (or empty if not particular file is relevant); linenumber is the line number of the code (or 0 if no line number
is relevant); ID is a unique number that identifies the message; and message is the
diagnostic message itself.
C.2
ENVIRONMENT (G.3.2)
C.2.1
The semantics of arguments to main (5.1.2.2.1)
The function main has no arguments, nor return value. It follows the prototype:
void main(void);
2012 Microchip Technology Inc.
DS52053B-page 479
MPLAB® XC8 C Compiler User’s Guide
C.3
IDENTIFIERS (G.3.3)
C.3.1
The number of significant initial characters (beyond 31) in an
identifier without external linkage (6.1.2)
By default, the first 31 characters are significant. This can be adjusted up to 255 by the
user.
C.3.2
The number of significant initial characters (beyond 6) in an
identifier with external linkage (6.1.2)
By default, the first 31 characters are significant. This can be adjusted up to 255 by the
user.
C.3.3
Whether case distinctions are significant in an identifier with
external linkage (6.1.2)
All characters in all identifiers are case sensitive.
C.4
CHARACTERS (G.3.4)
C.4.1
The members of the source and execution character sets,
except as explicitly specified in the Standard (5.2.1)
Both sets are identical to the ASCII character set.
C.4.2
The shift states used for the encoding of multibyte characters
(5.2.1.2)
There are no shift states.
C.4.3
The number of bits in a character in the execution character set
(5.2.4.2.1)
There are 8 bits in a character.
C.4.4
The mapping of members of the source character set (in
character and string literals) to members of the execution
character set (6.1.3.4)
The mapping is the identity function.
C.4.5
The value of an integer character constant that contains a
character or escape sequence not represented in the basic
execution character set or the extended character set for a wide
character constant (6.1.3.4)
It is the numerical value of the rightmost character.
C.4.6
The value of an integer character constant that contains more
than one character or a wide character constant that contains
more than one multibyte character (3.1.3.4)
Not supported.
C.4.7
Whether a plain char has the same range of values as signed
char or unsigned char (6.2.1.1)
A plain char is treated as an unsigned char.
DS52053B-page 480
2012 Microchip Technology Inc.
Implementation-Defined Behavior
C.5
INTEGERS (G.3.5)
C.5.1
The representations and sets of values of the various types of
integers (6.1.2.5)
See Section 5.4.2 “Integer Data Types”.
C.5.2
The result of converting an integer to a shorter signed integer,
or the result of converting an unsigned integer to a signed
integer of equal length, if the value cannot be represented
(6.2.1.2)
The low order bits of the original value are copied to the signed integer; or, all the low
order bits of the original value are copied to the signed integer.
C.5.3
The results of bitwise operations on signed integers (6.3)
The bitwise operations act as if the operand was unsigned.
C.5.4
The sign of the remainder on integer division (6.3.5)
The remainder has the same sign as the dividend. Table C-1 shows the expected sign
of the result of division for all combinations of dividend and divisor signs.
In the case where the second operand is zero (division by zero), the result will always
be zero.
TABLE C-1:
INTEGRAL DIVISION
Dividend
Divisor
Quotient
Remainder
+
+
+
+
-
+
-
-
+
-
-
+
-
-
+
-
C.5.5
The result of a right shift of a negative-valued signed integral
type (6.3.7)
The right shift operator sign extends signed values. Thus an object with the signed
int value 0x0124 shifted right one bit will yield the value 0x0092 and the value 0x8024
shifted right one bit will yield the value 0xC012.
Right shifts of unsigned integral values always clear the MSb of the result.
Left shifts (, the search first takes place in the directories
specified by -I options, then in the standard compiler directory (this is the directory
include found in the compiler install location.
For files specified in quotes, " ", the compilers searches the current working directory
first, then directories specified by -I options, then in the standard compiler directory.
If the first character of the filename is a /, then it is assumed that a full or relative path
to the file is specified. On Windows compilers, a path is also specified by either \ or a
DOS drive letter followed by a colon, e.g., C: appearing first in the filename.
C.13.4
The support of quoted names for includable source files (6.8.2)
Quoted names are supported.
C.13.5
The mapping of source file character sequences (6.8.2)
Source file characters are mapped to their corresponding ASCII values.
C.13.6
The behavior on each recognized #pragma directive (6.8.6)
See Section 5.14.4 “Pragma Directives”.
C.13.7
The definitions for __DATE__ and __TIME__ when, respectively,
the date and time of translation are not available (6.8.8)
These macros are always available from the environment.
DS52053B-page 484
2012 Microchip Technology Inc.
Implementation-Defined Behavior
C.14 LIBRARY FUNCTIONS (G.3.14)
C.14.1
The null constant to which the macro NULL expands (7.1.6)
The macro NULL expands to 0.
C.14.2
The diagnostic printed by and the termination behavior of the
assert function (7.2)
The function prints to stderr "Assertion failed: %s line %d: \"%s\"\n"
where the placeholders are replaced with the filename, line number and message
string, respectively. The program does not terminate.
C.14.3
The sets of characters tested for by the isalnum, isalpha,
iscntrl, islower, isprint, and isupper functions (7.3.1)
isalnum: ASCII characters a-z, A-Z, 0-9
isalpha: ASCII characters a-z, A-Z
iscntrl: ASCII values less than 32
islower: ASCII characters a-z
isprint: ASCII values between 32 and 126, inclusive
isupper: ASCII characters A-Z
C.14.4
The values returned by the mathematics functions on domain
errors (7.5.1)
acos(x) |x|>1.0 pi/2
asin(x) |x|>1.0 0.0
atan2(x,y) x=0,y=0 0.0
log(x) x