5.2.8. Conditional Compilation¶
Spicy scripts offer a basic form of conditional compilation through
@endif blocks, similar to a C preprocessor. For
now, this supports only a couple types of conditions that are useful
for feature and version testing. For example, the following
@if/@else block branches to different code based on the Spicy
@if SPICY_VERSION < 10000 <code for Spicy versions older than 1.0> @else <code for Spicy versions equal or newer than 1.0> @endif
@if directives can take one of the following forms:
@if [!] IDENTIFIER OPERATOR VALUE
- Compares the value of
VALUE. Supported comparison operators are
>=. See below for valid identifiers. If an identifier is not defined, its value is assumed to be zero.
@if [!] IDENTIFIER
- This is a shortcut for
@if [!] IDENTIFIER != 0.
By default, Spicy currently provides just one pre-defined identifier:
- The current Spicy version in numerical format (e.g., 10000 for version 1.0; see the output of
The Spicy plugin for Zeek defines a couple of additional identifiers.