include-guard

declaration/definition

Syntax
include-guard name

Argument definitions

name
Any valid OmniMark name.


Purpose

Prevents a file from being included twice, and thus prevents the file from being processed twice.

Sometimes it's desirable to write include files that themselves include other files. However, this can mean that the same file could get included twice, and therefore processed twice, which will almost certainly produce compile-time errors or other undesirable consequences.

To prevent an include file from being processed twice, use an include-guard declaration at the top of each include file you write. The include-guard declaration consists of the keyword include-guard followed by any valid OmniMark name. We suggest using the filename of the include file itself as the include-guard name:

  include-guard myfile.xin

The OmniMark compiler maintains a list of include-guard names as it compiles your program. If it encounters an include-guard name it has already seen before, it ignores the rest of the file in which the include-guard occurs. This ensures that an include file is never processed more than once.

All OmniMark-supplied include files have include-guard declarations.