module_env_snippet_25="$srcdir/src/module-env-25.h"
module_env_snippet_26="$srcdir/src/module-env-26.h"
module_env_snippet_27="$srcdir/src/module-env-27.h"
+emacs_major_version="${PACKAGE_VERSION%%.*}"
+AC_SUBST(emacs_major_version)
### Use -lpng if available, unless '--with-png=no'.
HAVE_PNG=no
can use only the parts of the module @acronym{API} that existed in
that version, since those parts are identical in later versions.
+@file{emacs-module.h} defines a preprocessor macro
+@code{EMACS_MAJOR_VERSION}. It expands to an integer literal which is
+the latest major version of Emacs supported by the header.
+@xref{Version Info}. Note that the value of
+@code{EMACS_MAJOR_VERSION} is a compile-time constant and does not
+represent the version of Emacs that is currently running and has
+loaded your module. If you want your module to be compatible with
+various versions of @file{emacs-module.h} as well as various versions
+of Emacs, you can use conditional compilation based on
+@code{EMACS_MAJOR_VERSION}.
+
We recommend that modules always perform the compatibility
verification, unless they do their job entirely in the initialization
function, and don't access any Lisp objects or use any Emacs functions
'extract_big_integer' to create and extract arbitrary-size integer
values.
+** emacs-module.h now defines a macro EMACS_MAJOR_VERSION that expands
+to the major version of the latest Emacs supported by the header.
+
\f
* Changes in Emacs 27.1 on Non-Free Operating Systems
#include <gmp.h>
#endif
+#define EMACS_MAJOR_VERSION @emacs_major_version@
+
#if defined __cplusplus && __cplusplus >= 201103L
# define EMACS_NOEXCEPT noexcept
#else
int
emacs_module_init (struct emacs_runtime *ert)
{
+ /* Check that EMACS_MAJOR_VERSION is defined and an integral
+ constant. */
+ char dummy[EMACS_MAJOR_VERSION];
+ assert (27 <= sizeof dummy);
+
if (ert->size < sizeof *ert)
{
fprintf (stderr, "Runtime size of runtime structure (%"pT" bytes) "