From 9bbf17539826a040eda45e88aabd358ed44fabf7 Mon Sep 17 00:00:00 2001 From: Philipp Stephani Date: Sat, 4 Jan 2020 13:54:29 +0100 Subject: [PATCH] Improve 'noexcept' support in C++17. In C++17, 'noexcept' is part of a function type and may be used in typedef declarations, see https://en.cppreference.com/w/cpp/language/noexcept_spec. * src/emacs-module.h.in: Mark function pointer type aliases as 'noexcept' in C++17. --- src/emacs-module.h.in | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/emacs-module.h.in b/src/emacs-module.h.in index e1bb00a3df6..cd75c0907e4 100644 --- a/src/emacs-module.h.in +++ b/src/emacs-module.h.in @@ -42,6 +42,12 @@ information how to write modules and use this header file. # define EMACS_NOEXCEPT #endif +#if defined __cplusplus && __cplusplus >= 201703L +# define EMACS_NOEXCEPT_TYPEDEF noexcept +#else +# define EMACS_NOEXCEPT_TYPEDEF +#endif + #ifdef __has_attribute #if __has_attribute(__nonnull__) # define EMACS_ATTRIBUTE_NONNULL(...) __attribute__((__nonnull__(__VA_ARGS__))) @@ -88,11 +94,11 @@ struct emacs_runtime typedef emacs_value (*emacs_function) (emacs_env *env, ptrdiff_t nargs, emacs_value *args, void *data) - EMACS_ATTRIBUTE_NONNULL (1); + EMACS_NOEXCEPT_TYPEDEF EMACS_ATTRIBUTE_NONNULL (1); /* Function prototype for module user-pointer and function finalizers. These must not throw C++ exceptions. */ -typedef void (*emacs_finalizer) (void *data); +typedef void (*emacs_finalizer) (void *data) EMACS_NOEXCEPT_TYPEDEF; /* Possible Emacs function call outcomes. */ enum emacs_funcall_exit -- 2.39.5