Supported Pragma Directives

Pragma directives supported by the Wave library
Pragma directives supported by the Wave tool

Pragma directives supported by the Wave library

The Wave preprocessor library natively supports the #pragma once and #pragma message("...") directives.

The #pragma once directive specifies that the file in which the pragma resides will be included (opened) only once. This may be used to optimize the preprocessing of larger compilation units, which include a lot of files. Note though, that the #pragma once directive is supported only, if the compile time constant BOOST_WAVE_SUPPORT_PRAGMA_ONCE was given during compilation of the library.

The #pragma message(...) directive generates a remark containing the given message text. This may be useful to generate status messages directly from the preprocessed file. Note though, that the #pragma message(...) directive is supported only, if the compile time constant BOOST_WAVE_SUPPORT_PRAGMA_MESSAGE was given during the compilation of the library. Note additionally, that the body of the message is preprocessed whenever the BOOST_WAVE_PREPROCESS_PRAGMA_BODY compile time constant was defined during compilation of the library.

Pragma directives supported by the Wave tool

The Wave preprocessor tool additionally supports specific #pragma directives, which may be used to control some of the tools features. These #pragma directives are implemented using the interpret_pragma() preprocessing hook (see here).

All directives described here are usable as conventional #pragma directives and as operator _Pragma (if variadics are enabled). So for instance the following directives are functionally identical:

    #pragma wave trace(enable)  


    _Pragma("wave trace(enable)")

All Wave specific pragmas must have the general form 'wave option[(value)]', where 'wave' is the specific keyword (which may be configured through the BOOST_WAVE_PRAGMA_KEYWORD compile time constant, see here for more information), 'option' is the concrete pragma functionality to trigger and 'value' is an optional value to be supplied to the 'option' functionality. The following table lists all possible pragma functions supported by the Wave library. For all recognised pragmas of this general form the interpret_pragma hook function from inside the preprocessing_hooks policy are called, so that the user of the library is responsible for the correct interpretation of these pragmas.

Supported pragmas

pragma option

pragma value




Enable or disable the tracing of the macro expansion process. This is needed, even if there is given the --trace command line option, because the trace output is generated only, if there is at least one trace(enable) pragma found.



Stop the execution of Wave and print out the given message. This is very helpful for direct debugging purposes.



Try to spawn the 'command' as a new operating system command and intercept the generated stdout and stderr. The stdout output of this command (if any) is retokenized and used as the replacement text for the whole pragma, the stderr output is ignored. The command is considered to be successful, if/when the return value is zero, otherwise an error is reported.
This #pragma is available only if the command line option -x is specified. The Wave driver will issue a remark if this command line argument is not specified and a #pragma wave system() directive is encountered


<no value>

The value restart set the current elapsed time to 0 and restarts the timer.

If no value is provided, the current elapsed time is printed to the std::cerr stream.

The values suspend and resume allow to temporarily stop and resume the timing.


line: [0 | 1 | push | pop]
preserve: [0 | 1 | 2 | push | pop]
output: ["filename" | null | default | push | pop]

The option(line: ...) directive allows to control, whether #line directives will be generated in the output stream. Specify either '0' or '1' as the option parameter. All other values will be flaged as illegal.

The option(preserve: ...) directive allows to control the amount of whitespace generated in the output stream. The value '0' removes any not needed whitespace, the value '1' keeps comments only and the value '2' does not remove any whitespace.

The option(output: ...) directive allows to specify the name of the file, where the output is generated to. Specify either a valid filename (which will be interpreted relative to directory of the processed file), the value null to disable the output at all, or the value default to use the output as specified on the command line using the --output/-o option.

The pragma values push and pop may be used for all of the options (line, preserve and output) to store and restore the current value of the corresponding option.

All pragmas not listed here but flagged as 'wave' are currently reported as errors. The handling of all remaining pragmas depends on the compilation constant BOOST_WAVE_RETURN_PRAGMA_DIRECTIVES, which allows to specify, if those pragmas are left unchanged in the output stream or not. Please note, that the operator _Pragma variant is always subject to full preprocessing, before the pragma itself is evaluated. The #pragma variant is subject to preprocessing only, if the BOOST_WAVE_PREPROCESS_PRAGMA_BODY compilation constant was specified during compilation. For more information about the possible compilation constants look here.

It is fairly easy to implement your own #pragma wave ... directives. All you have to do is to implement your own interpret_pragma preprocessing hook function (see here) which should handle the additional directives. For an example of how to do it, you may have a look at the Wave driver application, which implements all of the pragmas listed above with the help of a supplied interpret_pragma function (for instance the #pragma wave timer() directive).