lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


It was thus said that the Great Austin Einter once stated:
> I changed the order , that is first pushing string, next pushing length.
> Same crash observed.

Okay, you have:

	#include <lua5.2/lua.h>       
	#include <lua5.2/lualib.h>       
	#include <lua5.2/lualib.h>

What you need is:

	#include <lua5.2/lua.h>
	#include <lua5.2/lualib.h>
	#include <lua5.2/lauxlib.h>

Otherwise, you don't have proper prototypes for luaL_newstate() (which
explains the cast you have, to supress an error message most likely) and
luaL_checklstring() (again, which explains the cast).

You will also want to do the following:

	int rc;

	rc = luaL_loadstring(L,c_function);
	if (rc != 0)
	{
	  const char *err = lua_tostring(L,-1);
	  fprintf(stderr,"COMPILE: %s\n",err);
	  exit(EXIT_FAILURE);
	}
   
	rc = lua_pcall(L,0,0,0);
	if (rc != 0)
	{
	  const char *err = lua_tostring(L,-1);
	  fprintf(stderr,"ERROR: %s\n",err);
	  exit(EXIT_FAILURE);
	}

to catch runtime errors from Lua and report them.  In doing this, I found
several errors in the Lua code embedded in the C program.

  -spc (Hint:  you have mismatched levels of character escaping in the
	embedded Lua code)