User manual
MPLAB
®
XC8 C Compiler User’s Guide
DS52053B-page 88 2012 Microchip Technology Inc.
4.6.4 Message Format
By default, messages are printed in a human-readable format. This format can vary
from one compiler application to another, since each application reports information
about different file formats.
Some applications (for example, the parser) are typically able to pinpoint the area of
interest down to a position on a particular line of C source code, whereas other appli-
cations, such as the linker, can at best only indicate a module name and record number,
which is less directly associated with any particular line of code. Some messages relate
to issues in driver options which are in no way associated with any source code.
There are several ways of changing the format in which message are displayed, which
are discussed below.
The driver option -E (with or without a filename) alters the format of all displayed mes-
sages. See Section 4.8.3 “-E: Redirect Compiler Errors to a File”. Using this option
produces messages that are better suited to machine parsing, and are less
user-friendly. Typically each message is displayed on a single line. The general form of
messages produced when using the -E option is:
filename line: (message number) message string (type)
The -E option also has another effect. When used, the driver first checks to see if spe-
cial environment variables have been set. If so, the format dictated by these variables
are used as a template for all messages produced by all compiler applications. The
names of these environment variables are given in Table 4-4.
The value of these environment variables are strings that are used as templates for the
message format. Printf-like placeholders can be placed within the string to allow the
message format to be customized. The placeholders and what they represent are
indicated in Table 4-5.
If these options are used in a DOS batch file, two percent characters will need to be
used to specify the placeholders, as DOS interprets a single percent character as an
argument and will not pass this on to the compiler. For example:
SET HTC_ERR_FORMAT="file %%f: line %%l"
Environment variables, in turn, may be overridden by the driver options: --MSGFOR-
MAT, --WARNFORMAT and --ERRFORMAT, see Section 4.8.28 “--ERRFORMAT:
Define Format for Compiler Messages”. These options take a string as their argu-
ment. The option strings are formatted, and can use the same placeholders, as their
variable counterparts.
TABLE 4-4: MESSAGING ENVIRONMENT VARIABLES
Variable Effect
HTC_MSG_FORMAT All advisory messages
HTC_WARN_FORMAT All warning messages
HTC_ERR_FORMAT All error and fatal error messages
TABLE 4-5: MESSAGING PLACEHOLDERS
Placeholder Replacement
%a Application name
%c Column number
%f Filename
%l Line number
%n Message number
%s Message string (from MDF)