Make_export_header

Version

1.0

Description

Make_export_header scans C source files (*.c) for prototypes and variables to be exported, and creates a C header file (*.h) declaring them. This header file can then be included by other C files that want to use the exported routines or variables.

Author

Thomas Aglassinger <agi@sbox.tu-graz.ac.at>

Features

Template

make_export_header target.h source1.c source2.c ...

Usage

In the C source, you have to mark declarations of functions and variables to be exported with the pseudo-keyword "export". Because such a keyword does not exist, you have to define an empty macro before you can use it in the source. For example:

#define export /* empty */

/* a variable to be exported */
export char * hugo = "some text";

/* a function to be exported */
export int sepp(int resi, char * susi)
{
   ...
}

If this is stored in a source file "sepp.c", you can call

make_export_header export_sepp.h sepp.c

Essentially, "export_sepp.h" will contain:

extern char * hugo;
int sepp(int resi, char * susi);

Additionally, there is the usual #ifdef EXPORT_SEPP_H ... so that you can include "export_sepp.h" multiple times without causing problems. Finally, there is a little comment telling you not to modify this file because it is generated automatically.

Probably you want a single header file for all exported symbols in a project. For that, just specify the names of all the sources, for instance:

make_export_header export_sepp.h sepp.c hugo.c resi.c susi.c ...

Limitations

Bugs