Compilation flags

This guide describes the compiler flags supported by this library, including #define-based macros.

How to disable exceptions

To disable exceptions, the following flags must the passed to the compiler: -fno-exceptions -DQKA_SQD_DISABLE_EXCEPTIONS=1

When QKA_SQD_DISABLE_EXCEPTIONS is set to a non-zero value during compilation, the library will not throw exceptions. Instead, if there is an error, it will send a message to STDERR and call std::terminate. The default behavior of std::terminate is to abort the program, but this behavior can be configured by calling std::set_terminate. For an MPI program, it is recommended to install a custom handler that calls MPI_Abort instead.

How to disable run-time type information (RTTI)

This library does not require RTTI, so the following flag can optionally be passed to the compiler to disable it: -fno-rtti.

Example: Pass flags to cmake

Compiler flags are passed to cmake by using the -DCMAKE_CXX_FLAGS option. For instance, the test suite of this repository can be compiled without exceptions with the following commands:

mkdir -p build
cd build
cmake .. -DCMAKE_CXX_FLAGS="-fno-exceptions -DQKA_SQD_DISABLE_EXCEPTIONS=1 -DDOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS"
make

Note that compiling this repository’s test suite requires that you set #define DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS, as exceptions must be disabled in the doctest framework and the SQD library.

Concepts (C++20 and later)

This library is designed to use C++ concepts if they are available (that is, if the code is compiled according to C++20 or a later version of the standard). If possible, users are encouraged to use such a compiler when developing, as this will likely lead to better error messages from the compiler (such as when a template argument has an unexpected type).