Lichen

templates/exceptions.h

1027:dd0745ab8b8a
5 months ago Paul Boddie Reordered GCC arguments to prevent linking failures. Someone decided to change the GCC invocation or linking semantics at some point, meaning that libraries specified "too early" in the argument list no longer provide the symbols required by the program objects, whereas specifying them at the end of the argument list allows those symbols to be found and obtained.
     1 /* Exception definitions.     2      3 Copyright (C) 2016, 2017 Paul Boddie <paul@boddie.org.uk>     4      5 This program is free software; you can redistribute it and/or modify it under     6 the terms of the GNU General Public License as published by the Free Software     7 Foundation; either version 3 of the License, or (at your option) any later     8 version.     9     10 This program is distributed in the hope that it will be useful, but WITHOUT    11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS    12 FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more    13 details.    14     15 You should have received a copy of the GNU General Public License along with    16 this program.  If not, see <http://www.gnu.org/licenses/>.    17 */    18     19 #ifndef __EXCEPTIONS_H__    20 #define __EXCEPTIONS_H__    21     22 #include "cexcept.h"    23 #include "types.h"    24     25 /* Define the exception type. */    26     27 typedef struct    28 {    29     __attr arg;    30     unsigned char raising:1;    31     unsigned char raising_else:1;    32     unsigned char completing:1;    33 } __exc;    34     35 define_exception_type(__exc);    36 #undef define_exception_type    37     38 extern struct __exception_context __the_exception_context[1];    39     40 /* More specific macros. */    41     42 #define __Raise(value) __Throw ((__exc) {value, 1, 0, 0})    43 #define __RaiseElse(value) __Throw ((__exc) {value, 0, 1, 0})    44 #define __Return(value) __Throw ((__exc) {value, 0, 0, 1})    45 #define __Complete __Throw((__exc) {__NULL, 0, 0, 1})    46     47 #endif /* __EXCEPTIONS_H__ */