User manual

MPLAB
®
XC8 C Compiler User’s Guide
DS52053B-page 110 2012 Microchip Technology Inc.
4.8.47 --PROTO: Generate Prototypes
The --PROTO option is used to generate .pro files containing both ANSI C and K&R
style function declarations for all functions within the specified source files. Each .pro
file produced will have the same base name as the corresponding source file. Proto-
type files contain both ANSI C-style prototypes and old-style C function declarations
within conditional compilation blocks.
The extern declarations from each .pro file should be edited into a global header file,
which can then be included into all the C source files in the project. The .pro files may
also contain static declarations for functions which are local to a source file. These
static declarations should be edited into the start of the source file.
To demonstrate the operation of the --PROTO option, enter the following source code
as file test.c:
#include <stdio.h>
add(arg1, arg2)
int * arg1;
int * arg2;
{
return *arg1 + *arg2;
}
void printlist(int * list, int count)
{
while (count--)
printf("d " *list++);
putchar(’\n’);
}
If compiled with the command:
xc8
--CHIP=16F877AA --PROTO test.c
xc8 will produce test.pro containing the following declarations which may then be
edited as necessary:
/* Prototypes from test.c */
/* extern functions - include these in a header file */
#if PROTOTYPES
extern int add(int *, int *);
extern void printlist(int *, int);
#else /* PROTOTYPES */
extern int add();
extern void printlist();
#endif /* PROTOTYPES */