]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve 'noexcept' support in C++17.
authorPhilipp Stephani <phst@google.com>
Sat, 4 Jan 2020 12:54:29 +0000 (13:54 +0100)
committerPhilipp Stephani <phst@google.com>
Sat, 4 Jan 2020 12:54:29 +0000 (13:54 +0100)
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

index e1bb00a3df6a0cce13c6581ac3bf9e340eb7e494..cd75c0907e490d4d23ac0d98852e6bf6913f56a3 100644 (file)
@@ -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