diff options
Diffstat (limited to 'src/try.h')
-rw-r--r-- | src/try.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/try.h b/src/try.h new file mode 100644 index 00000000..f49ae05f --- /dev/null +++ b/src/try.h @@ -0,0 +1,21 @@ +// Copyright 2011-2023 David Robillard <d@drobilla.net> +// SPDX-License-Identifier: ISC + +#ifndef SERD_SRC_TRY_H +#define SERD_SRC_TRY_H + +#define TRY(st, exp) \ + do { \ + if (((st) = (exp))) { \ + return (st); \ + } \ + } while (0) + +#define TRY_FAILING(st, exp) \ + do { \ + if (((st) = (exp)) > SERD_FAILURE) { \ + return (st); \ + } \ + } while (0) + +#endif // SERD_SRC_TRY_H |