AutoGen - The Automated Program Generator: 3.4.25 make-header-guard - make self-inclusion guard

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

### 3.4.25 ‘`make-header-guard`’ - make self-inclusion guard

Usage: (make-header-guard name)
This function will create a `#ifndef`/`#define` sequence for protecting a header from multiple evaluation. It will also set the Scheme variable `header-file` to the name of the file being protected and it will set `header-guard` to the name of the `#define` being used to protect it. It is expected that this will be used as follows:

    [+ (make-header-guard "group_name") +]
    ...
    #endif /* [+ (. header-guard) +] */

    #include "[+ (. header-file)  +]"

The `#define` name is composed as follows:

1. The first element is the string argument and a separating underscore.
2. That is followed by the name of the header file with illegal characters mapped to underscores.
3. The end of the name is always, "`_GUARD`".
4. Finally, the entire string is mapped to upper case.

The final `#define` name is stored in an SCM symbol named `header-guard`. Consequently, the concluding `#endif` for the file should read something like:

    #endif /* [+ (. header-guard) +] */

The name of the header file (the current output file) is also stored in an SCM symbol, `header-file`. Therefore, if you are also generating a C file that uses the previously generated header file, you can put this into that generated file:

    #include "[+ (. header-file) +]"

Obviously, if you are going to produce more than one header file from a particular template, you will need to be careful how these SCM symbols get handled.

Arguments:
name - header group name

This document was generated by Bruce Korb on May, 24 2008 using texi2html 1.78.