GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
panic.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 2024-2025 The Octave Project Developers
4//
5// See the file COPYRIGHT.md in the top-level directory of this
6// distribution or <https://octave.org/copyright/>.
7//
8// This file is part of Octave.
9//
10// Octave is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// Octave is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Octave; see the file COPYING. If not, see
22// <https://www.gnu.org/licenses/>.
23//
24////////////////////////////////////////////////////////////////////////
25
26#if ! defined (octave_panic_h)
27#define octave_panic_h 1
28
29#include "octave-config.h"
30
31#include <cstdarg>
32
33OCTAVE_NORETURN
34extern OCTINTERP_API void vpanic (const char *fmt, va_list args);
35
36OCTAVE_FORMAT_PRINTF (1, 2)
37OCTAVE_NORETURN
38extern OCTINTERP_API void panic (const char *fmt, ...);
39
40// To allow the __FILE__ and __LINE__ macros to work as expected, the
41// panic_impossible, panic_if, and panic_unless symbols must be defined
42// as macros.
43
44#if defined (NDEBUG)
45
46# define panic_impossible() do { } while (0)
47
48# define panic_if(cond) do { } while (0)
49
50# define panic_unless(cond) do { } while (0)
51
52#else
53
54# define panic_impossible() \
55 ::panic ("impossible state reached in file '%s' at line %d", __FILE__, __LINE__)
56
57# define panic_if(cond) do { if (cond) panic_impossible (); } while (0)
58
59# define panic_unless(cond) panic_if (! (cond))
60
61#endif
62
63#endif
OCTAVE_NORETURN void panic(const char *fmt,...)
Definition panic.cc:45
OCTAVE_NORETURN void vpanic(const char *fmt, va_list args)
Definition panic.cc:36