ref: dd0a0972b4428771e6a3887da2210c7c9dd40f9c
parent: 1780d0ea73433a4548fe4bc073bdf2964b6d9b63
author: Tor Andersson <[email protected]>
date: Thu Oct 21 10:04:52 EDT 2021
Add JS_VERSION_MAJOR/MINOR/PATCH defines to mujs.h A macro JS_CHECKVERSION(major, minor, patch) can be used to test the version if your code depends on API features added in a given version. #if JS_CHECKVERSION(1, 2, 0) ... use new API ... #else ... don't use new API ... #endif
--- a/main.c
+++ b/main.c
@@ -356,6 +356,8 @@
}
if (interactive) {
+ printf("Welcome to MuJS %d.%d.%d.\n",
+ JS_VERSION_MAJOR, JS_VERSION_MINOR, JS_VERSION_PATCH);
if (isatty(0)) {
using_history();
rl_bind_key('\t', rl_insert);
--- a/mujs.h
+++ b/mujs.h
@@ -7,6 +7,13 @@
extern "C" {
#endif
+#define JS_VERSION_MAJOR 1
+#define JS_VERSION_MINOR 2
+#define JS_VERSION_PATCH 0
+
+#define JS_VERSION (JS_VERSION_MAJOR * 10000 + JS_VERSION_MINOR * 100 + JS_VERSION_PATCH)
+#define JS_CHECKVERSION(x,y,z) (JS_VERSION >= ((x) * 10000 + (y) * 100 + (z)))
+
/* noreturn is a GCC extension */
#ifdef __GNUC__
#define JS_NORETURN __attribute__((noreturn))