Skip to content

Instantly share code, notes, and snippets.

@jaredkrinke
Last active March 31, 2025 18:42
Show Gist options
  • Select an option

  • Save jaredkrinke/9347caa418f9b72fe04c80d4897431af to your computer and use it in GitHub Desktop.

Select an option

Save jaredkrinke/9347caa418f9b72fe04c80d4897431af to your computer and use it in GitHub Desktop.
Minimal Lua5.1 test app for POSIX (compiled size on x64 Debian is ~130 KB with static Lua, dynamic libc/libm)
#include <stdio.h>
#include <stdlib.h>
#include <lua.h>
#include <lauxlib.h>
int main()
{
lua_State* L = luaL_newstate();
char* line = NULL;
size_t n = 0;
for (;;) {
if (getline(&line, &n, stdin) <= 1) {
break;
}
luaL_dostring(L, line);
printf("> %s\n", lua_tostring(L, -1));
}
free(line);
lua_close(L);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment