diff --git a/pdlua.c b/pdlua.c
index 33fab88923374752ff72af1ce29fdf81160d97e6..70557bcf0774cd768f9d32363ab4b4c501867362 100644
--- a/pdlua.c
+++ b/pdlua.c
@@ -1652,7 +1652,11 @@ void pdlua_setup(void)
     char*               luaver = "lua 0.6~svn (GPL) 2008 Claude Heiland-Allen <claude@mathr.co.uk>";
     char                compiled[MAXPDSTRING];
     char                luaversionStr[MAXPDSTRING];
+#if LUA_VERSION_NUM	< 504
     const lua_Number    *luaversion = lua_version (NULL);
+#else
+    const lua_Number    luavers = lua_version (NULL), *luaversion = &luavers;
+#endif
     int                 lvm, lvl;
 
 #ifndef BUILD_DATE