lua-users home
lua-l archive

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


On Wed, Oct 11, 2000 at 04:02:17PM -0200, Roberto Ierusalimschy wrote:
> > Could all API functions be identified as such in header and code with a 
> > macro such as LUA_API_FUNCTION, so that those of us who would like to build 
> > Lua as a Windows DLL can do so easily? 
> 
> Do you mean a macro at the beginning of each declaration, such as
> 
>   LUA_API_FUNCTION void lua_settable (...);
> 
>   LUA_API_FUNCTION void lua_settable (...) { ...
> 
> Is this enough for all Windows uses? Don't you need another macro between
> the type and the function name for things such as `cdecl' (or something
> like that)?

The idea is that you insert LUA_API_FUNCTION before each of them, then
    #ifndef LUA_API_FUNCTION
    #define LUA_API_FUNCTION
    #endif

Then if someone wants to make Lua buildable as a DLL, they just have
to add above that:

   #ifdef BUILD_AS_DLL
   #define LUA_API_FUNCTION	extern __declspec(dllexport) [...]
   #endif

And define "BUILD_AS_DLL" in the Makefile (along with the linking
flags).  All of the exports are done automatically because you've
specified them ahead of time.  Much more convenient than as it now
stands, where you have to add them in yourself when you get the new
version of the code.

Bret
-- 
Bret Mogilefsky  ** mogul@playstation.sony.com **  Programmer, SCEA R&D