[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: setting lua cpath to include ?51.dll
- From: Terence Martin <lua@...>
- Date: Wed, 18 Apr 2012 10:41:27 -0700
On Wed, 18 Apr 2012 19:00:32 +0530
forum <forumme5487@live.com> wrote:
> How can I set the "package.cpath" to also search for ?51.dlls instead
> only ?.dlls?
>
> From within c/c++.
>
I'll just send that reply again since I think the other one isn't going
to end up on the list (apologies for the duplication if it does).
You could modify LUA_CPATH_DEFAULT in luaconf.h if you're compiling
Lua yourself.
Otherwise, something like the following untested code. Play with the
lua_pushfstring to get you the path the way you want; this version puts
your custom paths in front of the default cpath.
Also you should probably use %s and LUA_CDIR instead of "!\\" for
ultimate awesomeness.
/* Get the package table. */
lua_getglobal (L, "package");
/* Push a new path. */
lua_pushfstring (L, "!\\?51.dll;!\\loadall51.dll;.\\?51.dll;%s",
LUA_CPATH_DEFAULT);
/* Set the path in. */
lua_setfield (L, -2, "cpath");
/* Done with package table now. */
lua_pop (L, 1);