Microchip Technology SW006023-2N Data Sheet

Page of 238
MPLAB
®
 XC32 C/C++ COMPILER
USER’S GUIDE
 2012 Microchip Technology Inc.
DS51686E-page 159
Chapter 13.  Library Routines
13.1
USING LIBRARY ROUTINES
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 func-
tion 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.
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.
#include <math.h>    // declare function prototype for sqrt
int main(void)
{
  double i;
  // sqrt referenced; sqrt will be linked in from library file
  i = sqrt(23.5);
}