[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Size and dependencies of bit.dll (LuaForWindows)
- From: David Manura <dm.lua@...>
- Date: Tue, 28 Sep 2010 22:20:45 -0400
2010/9/27 J.Jørgen von Bargen <firstname.lastname@example.org>:
> All the time I wondered about the dependencies and size of bit.dll.
> + BOOL WINAPI DllMain( .....
> And WOW, this reduced bit.dll from 20480 to 4096 bytes and completly
> removed the dependency from any msvcrt*.dll. I did not see any bad
> side effects yet, the msvctest.bat runs flawlessly.
> Do you have any cons for this approach?
By default the compiler will define its own DLL entry point (DllMain)
and in that do things like initialize the C standard library. You're
in effect bypassing that, which is fine because LuaBitOp doesn't
directly need any standard library functionality like malloc or
printf. It does potentially trigger mallocs in
luaopen_bit/luaL_register in order to allocate the module table, but
any memory allocation is entirely handled instead by the Lua DLL.
Even if you needed malloc but wanted to avoid the CRT, you could still
redefine it in terms of Win32 API calls or (more portably)
To limit littering the source too much, try linker options like MSVC's
/NOENTRY & /ENTRY and gcc's -nostdlib, IIRC. I wouldn't use that
NOWIN98 flag pragma since it's obsolete in MSVC2010.