Техническая Спецификация для Microchip Technology SW006022-2
MPLAB
®
XC16 C COMPILER
USER’S GUIDE
2012 Microchip Technology Inc.
DS52071B-page 197
Chapter 14. Library Routines
Many library functions or routines (and any associated variables) will be automatically
linked into a program once they have been referenced in your source code. The use of
a function from one library file will not include any other functions from that library. Only
used library functions will be linked into the program output and consume memory.
linked into a program once they have been referenced in your source code. The use of
a function from one library file will not include any other functions from that library. Only
used library functions will be linked into the program output and consume memory.
Library and precompiled object files are stored in the compiler’s installation directory
structure.
structure.
Your program will require declarations for any functions or symbols used from libraries.
These are contained in the standard C header (.h) files. Header files are not library
files and the two files types should not be confused. Library files contain precompiled
code, typically functions and variable definitions; the header files provide declarations
(as opposed to definitions) for functions, variables and types in the library files, as well
as other preprocessor macros.
These are contained in the standard C header (.h) files. Header files are not library
files and the two files types should not be confused. Library files contain precompiled
code, typically functions and variable definitions; the header files provide declarations
(as opposed to definitions) for functions, variables and types in the library files, as well
as other preprocessor macros.
The include directories, under the compiler’s installation directory, are where the
compiler stores the standard C library system header files. The installation will
automatically locate its bundled include files.
compiler stores the standard C library system header files. The installation will
automatically locate its bundled include files.
Some libraries require manual inclusion in your project, or require special options to
use. See the 16-Bit Language Tools Libraries (DS51456) for questions about particular
libraries.
use. See the 16-Bit Language Tools Libraries (DS51456) for questions about particular
libraries.
Libraries which are found automatically include:
• Standard C library
• dsPIC30 support libraries
• Standard IEEE floating point library
• Device peripheral library
EXAMPLE 14-1:
USING THE MATH LIBRARY
#include <math.h> // declare function prototype for sqrt
void main(void)
{
double i;
// sqrt referenced; sqrt will be linked in from library file
i = sqrt(23.5);
}