Microchip Technology XC8 Standard Compiler (Workstation) SW006021-1 SW006021-1 ユーザーズマニュアル

製品コード
SW006021-1
ページ / 518
MPLAB
®
 XC8 C COMPILER
USER’S GUIDE
 2012 Microchip Technology Inc.
DS52053A-page 13
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 proj-
ects 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
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 hun-
dred 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 com-
piler vendors can base their products on different technologies, implement different fea-
tures 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) pub-
lishes standards for many disciplines, including programming languages. The ANSI C 
Standard is a universally adopted standard for the C programming language.