lua-users home
lua-l archive

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


Hi, list!

I'm trying to load minimal C module with LuaJIT:

  LUALIB_API int luaopen_mod(lua_State * L)
  {
    lua_newtable(L);
    lua_pushcfunction(L, Lhi);
    lua_setfield(L, -2, "hi");
    return 1;
  }

  local mod = require("mod")

This works with plain Lua, but doesn't with LuaJIT. In LuaJIT that
require() call returns true instead of my module's table. Am I missing
something?

$ /usr/local/bin/lua -v
Lua 5.1.3  Copyright (C) 1994-2008 Lua.org, PUC-Rio

$ luajit -v
Lua 5.1.3  Copyright (C) 1994-2008 Lua.org, PUC-Rio
LuaJIT 1.1.4  Copyright (C) 2005-2008 Mike Pall, http://luajit.org/

$ make clean
$ make

$ /usr/local/bin/lua test.lua
OK

$ luajit -O test.lua
luajit: test.lua:2: not a table
stack traceback:
	[C]: in function 'assert'
	test.lua:2: in main chunk
	[C]: ?

$ luajit -O0 test.lua
luajit: test.lua:2: not a table
stack traceback:
	[C]: in function 'assert'
	test.lua:2: in main chunk
	[C]: ?

Minimal example attached.
Thanks in advance,
Alexander.

Attachment: example.tar.gz
Description: GNU Zip compressed data