From d2ebdc045bae7c8ed0e62729ca455444c076b1bb Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 18 Feb 2009 14:20:56 -0300 Subject: new macro 'lua_checkversion' to check whether core and application are compatible --- lapi.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'lapi.c') diff --git a/lapi.c b/lapi.c index 9af75b17..86b591c4 100644 --- a/lapi.c +++ b/lapi.c @@ -1,5 +1,5 @@ /* -** $Id: lapi.c,v 2.67 2008/07/04 18:27:11 roberto Exp roberto $ +** $Id: lapi.c,v 2.68 2008/08/01 17:01:16 roberto Exp roberto $ ** Lua API ** See Copyright Notice in lua.h */ @@ -121,6 +121,16 @@ LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) { } +LUA_API void lua_checkversion_ (lua_State *L, int version) { + lua_lock(L); + if (version != LUA_VERSION_NUM) + luaG_runerror(L, "application and Lua core using different Lua versions"); + if (G(L)->nilobjp != luaO_nilobject) + luaG_runerror(L, "application using two incompatible Lua VMs"); + lua_unlock(L); +} + + /* ** basic stack manipulation -- cgit v1.2.3-55-g6feb