]> code.delx.au - gnu-emacs/commitdiff
* src/emacs-module.h: Fix finalizer typedef for C++11
authorAurélien Aptel <aurelien.aptel@gmail.com>
Mon, 30 Nov 2015 22:53:40 +0000 (23:53 +0100)
committerAurélien Aptel <aurelien.aptel@gmail.com>
Mon, 30 Nov 2015 22:53:40 +0000 (23:53 +0100)
C++11 standard doesn't allow exception-specification in typedef.
The workaround is to declare a dummy function prototype and use
decltype on it.

src/emacs-module.h

index dce5301ab0f1bb929589bce44d46dd1e0066c362..a3aa5017a4ed547635dd0e1cfb21c89c7578c6ee 100644 (file)
@@ -26,8 +26,19 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #if defined __cplusplus && __cplusplus >= 201103L
 # define EMACS_NOEXCEPT noexcept
+
+/* Function prototype for module user-pointer finalizers.
+
+   NOTE: C++11 15.4: An exception-specification shall not appear in a
+                     typedef declaration or alias-declaration.
+
+*/
+void emacs_dummy_finalizer_function (void *) noexcept;
+typedef decltype(emacs_dummy_finalizer_function) *emacs_finalizer_function;
+
 #else
 # define EMACS_NOEXCEPT
+typedef void (*emacs_finalizer_function) (void *);
 #endif
 
 #ifdef __cplusplus
@@ -64,9 +75,6 @@ typedef int (*emacs_init_function) (struct emacs_runtime *ert);
 typedef emacs_value (*emacs_subr) (emacs_env *env, ptrdiff_t nargs,
                                   emacs_value args[], void *data);
 
-/* Function prototype for module user-pointer finalizers.  */
-typedef void (*emacs_finalizer_function) (void *) EMACS_NOEXCEPT;
-
 /* Possible Emacs function call outcomes.  */
 enum emacs_funcall_exit
 {