lua-users home
lua-l archive

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


On 10 June 2013 06:47, Matt Eisan <mattjeisan@gmail.com> wrote:
> I noticed most, if not all, examples of programs that involve writing
> modules for Lua define all C functions as static. Why is this and why isbot
> necessary?

static functions are only visible within their own file. Non-static
functions can be called from outside of their own file.

http://stackoverflow.com/questions/5319361/static-function-in-c
http://stackoverflow.com/questions/1665250/why-declare-a-variable-or-function-static-in-c

In most Lua modules, the only function you want to export to outside
code is your luaopen_xxx function (which Lua needs to be able to call
to load your module). The other functions are generally only intended
for use by your own module or from within Lua.