Last active
August 29, 2015 14:14
-
-
Save Houdini/62a1c700861de0e1b8b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lua test.lua | |
lua: test.lua:5: attempt to index a nil value (global 'zstring') | |
stack traceback: | |
test.lua:5: in main chunk | |
[C]: in ? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "lua.h" | |
#include "lualib.h" | |
#include "lauxlib.h" | |
#include <string.h> | |
/* gcc zstring.c -Wall -shared -o zstring.so */ | |
static int zst_strlen(lua_State *L) | |
{ | |
size_t len; | |
len = strlen(lua_tostring(L, 1)); | |
lua_pushnumber(L, len); | |
return 1; | |
} | |
int luaopen_zstring(lua_State *L) | |
{ | |
lua_register(L,"zst_strlen", zst_strlen); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment