C program header file creator


Whenever you write a C program you have to maintain the function prototypes in the file as well as in the header file. Maintaining the same information in two locations is the source of error. Instead type all information you need in the header file into the C source file into comments and create the header file automatically using this headederer.pl Perl script to extract the information from the C source file and to create the function prototypes automatically.

This tool is as simple as it can be, but is very powerful.

Start your program with the lines:

/*
FILE xxx.c
HEADER xxx.h

and the script will know that the header file is named xxx.h

After this any line between

TO_HEADER:

and a line

*/

will be copied into the header file almost verbatim. The copying process chops off all

//comment

like C++ comments.

Function prototypes should be started with a line containing:

/*FUNCTION*/

(All capital letters and no space.) Following this the prototype of the function is going to be copied into the header file until a line containing the two characters

 ){
is found. This closes the prototype and is converted to ); to be correct.

The header file is enclosed automatically

#ifndef __XXX_H__
#define __XXX_H__ 1

  ...

#endif

not to be included twice.

The code can be downloaded here as Perl and also here as ScriptBasic code.