Files
MeanField_SERiF/src/include/serif/utils/warnings/warning.hpp
Emily Boudreaux c44584c1e7 feat(quadrature): quadrature system brought over
Ported and dramatically cleaned up the quadrature system. This includes centralizing all field definitions
2026-09-19 07:35:57 -04:00

24 lines
1.3 KiB
C++

#pragma once
// TODO: Sort out how to get this from a meson option and ideally not use any macros or at least resolve them to type safe compile time values
#define DISABLE_WARNING 0
#include <string_view>
#include <format>
#include <print>
#include <cstdio>
#include "serif/utils/misc/terminal/colors.hpp"
// We may want to do a similar thing to what we did with errors and introduce a SERiFWarningCode enum and a serif_warning function that takes a warning code and a message. This would allow us to have more structured warnings and potentially allow users to filter or handle warnings based on their codes. However, for now, we will keep it simple with just a message.
namespace serif::utils::warnings {
void serif_warning(const std::string_view message, auto... args) {
if constexpr (DISABLE_WARNING == 0) { // This is a constexpr so that the compiler can optimize out the warnings to a no-op
if (misc::terminal::supports_ansi(stderr)) {
std::println(stderr, "{}{}{}: {}", misc::terminal::a_yellow, "Warning", misc::terminal::a_reset, std::vformat(message, std::make_format_args(args...)));
} else {
std::println(stderr, "Warning: {}", std::vformat(message, std::make_format_args(args...)));
}
}
}
}