Loading...
Searching...
No Matches
Diagnostics

Definition

Diagnostic directives for the fpx preprocessor.

This module implements the handling of the preprocessor directives #error and #warning, allowing source files to emit user-defined diagnostics during preprocessing.

These directives are commonly used to enforce configuration requirements, reject unsupported platforms, report deprecated features, or notify users about assumptions made during compilation.

Supported directives:

  • #error Emits a fatal diagnostic and immediately terminates preprocessing.
  • #warning Emits a non-fatal diagnostic message while allowing preprocessing to continue normally.

The diagnostic text consists of the remainder of the directive line following the keyword itself.

Note
The routines implemented in this module do not perform macro expansion on the diagnostic message. Any expansion must have been completed before the directive handler is invoked.

Examples

  1. Reject unsupported platforms:
    #ifdef __VAX__
    #error
    #endif
  2. Enforce configuration requirements:
    #ifndef MPI_VERSION
    #error
    #endif
  3. Warn about deprecated functionality:
    #ifdef USE_LEGACY_SOLVER
    #warning
    #endif
  4. Notify users of unusual configurations:
    #if PRECISION > 64
    #warning
    #endif
  5. Emit custom informational messages:
    #warning
See also
logging
context

Methods

◆ handle_error()

subroutine, public handle_error ( type(context), intent(in) ctx,
type(macro), dimension(:), intent(inout), allocatable macros,
character(*), intent(in) token )

Process a #error directive.

Extracts the message following the directive keyword and immediately terminates preprocessing using an error stop statement.

This directive is intended for unrecoverable situations such as unsupported targets, invalid configurations, or missing prerequisites.

Parameters
[in]ctxSource context containing the complete #error directive.
[in,out]macrosActive macro table. Present for interface consistency and not modified.
[in]tokenDirective keyword, typically "error".

Definition at line 104 of file diagnostics.f90.

◆ handle_warning()

subroutine, public handle_warning ( type(context), intent(in) ctx,
type(macro), dimension(:), intent(inout), allocatable macros,
character(*), intent(in) token )

Process a #warning directive.

Extracts the message following the directive keyword and writes it to the standard output stream without interrupting preprocessing.

This directive is intended for non-fatal conditions such as deprecated features, unusual build settings, or informational notices.

Parameters
[in]ctxSource context containing the complete #warning directive.
[in,out]macrosActive macro table. Present for interface consistency and not modified.
[in]tokenDirective keyword, typically "warning".

Definition at line 131 of file diagnostics.f90.