Replace __noreturn with C++11 [[noreturn]]
This allows non-GNU-C compilers to see the attribute.
This commit is contained in:
parent
a3bf147768
commit
15057af2f9
|
@ -31,14 +31,6 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
||||||
#include "dsx-ns.h"
|
#include "dsx-ns.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#define __noreturn __attribute__ ((noreturn))
|
|
||||||
#else
|
|
||||||
#define __noreturn
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace dcx {
|
namespace dcx {
|
||||||
|
|
||||||
void Warning_puts(const char *str) __attribute_nonnull();
|
void Warning_puts(const char *str) __attribute_nonnull();
|
||||||
|
@ -48,26 +40,28 @@ void Warning(const char *fmt,...) __attribute_format_printf(1, 2); //print ou
|
||||||
void set_warn_func(void (*f)(const char *s));//specifies the function to call with warning messages
|
void set_warn_func(void (*f)(const char *s));//specifies the function to call with warning messages
|
||||||
void clear_warn_func();//say this function no longer valid
|
void clear_warn_func();//say this function no longer valid
|
||||||
#endif
|
#endif
|
||||||
__noreturn
|
|
||||||
__attribute_nonnull()
|
__attribute_nonnull()
|
||||||
|
[[noreturn]]
|
||||||
void Error_puts(const char *file, unsigned line, const char *func, const char *str);
|
void Error_puts(const char *file, unsigned line, const char *func, const char *str);
|
||||||
#define Error_puts(F) Error_puts(__FILE__, __LINE__, __func__, F)
|
#define Error_puts(F) Error_puts(__FILE__, __LINE__, __func__, F)
|
||||||
__noreturn
|
|
||||||
__attribute_format_printf(4, 5)
|
__attribute_format_printf(4, 5)
|
||||||
__attribute_nonnull()
|
__attribute_nonnull()
|
||||||
|
[[noreturn]]
|
||||||
void Error(const char *file, unsigned line, const char *func, const char *fmt,...); //exit with error code=1, print message
|
void Error(const char *file, unsigned line, const char *func, const char *fmt,...); //exit with error code=1, print message
|
||||||
#define Error(F,...) dxx_call_printf_checked(Error,(Error_puts),(__FILE__, __LINE__, __func__),(F),##__VA_ARGS__)
|
#define Error(F,...) dxx_call_printf_checked(Error,(Error_puts),(__FILE__, __LINE__, __func__),(F),##__VA_ARGS__)
|
||||||
|
|
||||||
__noreturn
|
[[noreturn]]
|
||||||
void UserError_puts(const char *str, std::size_t);
|
void UserError_puts(const char *str, std::size_t);
|
||||||
|
|
||||||
template <std::size_t len>
|
template <std::size_t len>
|
||||||
__noreturn
|
[[noreturn]]
|
||||||
static inline void UserError_puts(const char (&str)[len])
|
static inline void UserError_puts(const char (&str)[len])
|
||||||
{
|
{
|
||||||
UserError_puts(str, len - 1);
|
UserError_puts(str, len - 1);
|
||||||
}
|
}
|
||||||
void UserError(const char *fmt, ...) __noreturn __attribute_format_printf(1, 2);
|
|
||||||
|
[[noreturn]]
|
||||||
|
void UserError(const char *fmt, ...) __attribute_format_printf(1, 2);
|
||||||
|
|
||||||
}
|
}
|
||||||
#define DXX_STRINGIZE_FL2(F,L,S) F ":" #L ": " S
|
#define DXX_STRINGIZE_FL2(F,L,S) F ":" #L ": " S
|
||||||
|
@ -129,5 +123,3 @@ static inline void d_debugbreak()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -59,13 +59,15 @@ void clear_warn_func()
|
||||||
constexpr auto warn_func = &warn_printf;
|
constexpr auto warn_func = &warn_printf;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
static void print_exit_message(const char *exit_message, size_t len)
|
static void print_exit_message(const char *exit_message, size_t len)
|
||||||
{
|
{
|
||||||
con_puts(CON_CRITICAL, exit_message, len);
|
con_puts(CON_CRITICAL, exit_message, len);
|
||||||
msgbox_error(exit_message);
|
msgbox_error(exit_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
__noreturn
|
[[noreturn]]
|
||||||
static void abort_print_exit_message(const char *exit_message, size_t len)
|
static void abort_print_exit_message(const char *exit_message, size_t len)
|
||||||
{
|
{
|
||||||
print_exit_message(exit_message, len);
|
print_exit_message(exit_message, len);
|
||||||
|
@ -73,13 +75,15 @@ static void abort_print_exit_message(const char *exit_message, size_t len)
|
||||||
std::abort();
|
std::abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
__noreturn
|
[[noreturn]]
|
||||||
static void graceful_print_exit_message(const char *exit_message, size_t len)
|
static void graceful_print_exit_message(const char *exit_message, size_t len)
|
||||||
{
|
{
|
||||||
print_exit_message(exit_message, len);
|
print_exit_message(exit_message, len);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void (Error_puts)(const char *filename, const unsigned line, const char *func, const char *str)
|
void (Error_puts)(const char *filename, const unsigned line, const char *func, const char *str)
|
||||||
{
|
{
|
||||||
char exit_message[MAX_MSG_LEN]; // don't put the new line in for dialog output
|
char exit_message[MAX_MSG_LEN]; // don't put the new line in for dialog output
|
||||||
|
|
Loading…
Reference in a new issue