Microchip Technology SW006022-1N Data Sheet

Page of 338
MPLAB
®
 XC16 C Compiler User’s Guide
DS52071B-page 202
 2012 Microchip Technology Inc.
Macro expansion using arguments can use the # character to convert an argument to 
a string, and the ## sequence to concatenate arguments. If two expressions are being 
concatenated, consider using two macros in case either expression requires substitu-
tion itself, so for example
#define paste1(a,b)  a##b
#define paste(a,b) paste1(a,b)
lets you use the paste macro to concatenate two expressions that themselves may 
require further expansion. Remember that once a macro identifier has been expanded, 
it will not be expanded again if it appears after concatenation.
For implementation-defined behavior of preprocessing directives, see 
Section A.14 “Preprocessing Directives”.
16.4
PREDEFINED MACRO NAMES
The compiler predefines several macros which can be tested by conditional directives 
in source code. Constants that have been deprecated may be found in Appendix 
E. “Deprecated Features”
.
16.4.1
Compiler Version Macro
The compiler will define the constant __XC16_VERSION__ , giving a numeric value to 
the version identifier. This can be used to take advantage of new compiler features 
while remaining backwardly compatible with older versions.
The value is based upon the major and minor version numbers of the current release. 
For example, release version 1.00 will have a __XC16_VERSION__ definition of 1000. 
This macro can be used, in conjunction with standard preprocessor comparison state-
ments, to conditionally include/exclude various code constructs.
The current definition of __XC16_VERSION__ can be discovered by adding 
--version
 to the command line, or by inspecting the README.html file that came 
with the release.
#ifdef
Include source lines if preprocessor 
symbol defined
#ifdef FLAG
 
  do_loop();
#elif SIZE == 5
  skip_loop();
#endif
#ifndef
Include source lines if preprocessor 
symbol not defined
#ifndef FLAG
  jump();
#endif
#include
Include text file into source
#include <stdio.h>
 
#include "project.h" 
#line
Specify line number and file name for 
listing
#line 3 final
#pragma
Compiler specific options
#undef
Undefines preprocessor symbol
#undef FLAG
#warning
Generate a warning message
#warning Length not set
TABLE 16-1:
PREPROCESSOR DIRECTIVES (CONTINUED)
Directive
 Meaning
 Example