Skip to content

Commit

Permalink
api: mark as noreturn the jule::panic function
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Apr 23, 2024
1 parent aa713e2 commit 3b5a0c4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions api/panic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
#define __JULE_PANIC_HPP

#include <iostream>
#include <vector>
#include "impl_flag.hpp"

#ifdef OS_WINDOWS
#include "windows.h"
#include <vector>

#include "types.hpp"
#include "platform.hpp"
Expand All @@ -21,7 +22,8 @@ namespace jule
{
constexpr signed int EXIT_PANIC = 2;

inline void panic(const std::string &expr) noexcept
__attribute__((noreturn))
void panic(const std::string &expr)
{
std::cerr << "panic: ";
#ifdef OS_WINDOWS
Expand All @@ -32,6 +34,7 @@ namespace jule
std::cerr << expr << std::endl;
#endif
std::exit(jule::EXIT_PANIC);
__builtin_unreachable();
}

} // namespace jule
Expand Down

0 comments on commit 3b5a0c4

Please sign in to comment.