mirror of
https://codeberg.org/ProgramSnail/lang.git
synced 2025-12-06 06:58:46 +00:00
29 lines
672 B
C++
29 lines
672 B
C++
#pragma once
|
|
|
|
#include <iostream>
|
|
#include <string>
|
|
|
|
namespace error_handling {
|
|
|
|
inline void handle_general_error(const std::string &message) {
|
|
std::cerr << "\x1b[1;31mGeneral Error:\x1b[0m " << message << ".\n";
|
|
exit(1);
|
|
}
|
|
|
|
} // namespace error_handling
|
|
|
|
namespace utils {
|
|
|
|
// in std from c++23
|
|
[[noreturn]] inline void unreachable() {
|
|
// Uses compiler specific extensions if possible.
|
|
// Even if no extension is used, undefined behavior is still raised by
|
|
// an empty function body and the noreturn attribute.
|
|
#if defined(_MSC_VER) && !defined(__clang__) // MSVC
|
|
__assume(false);
|
|
#else // GCC, Clang
|
|
__builtin_unreachable();
|
|
#endif
|
|
}
|
|
|
|
} // namespace utils
|