lua-users home
lua-l archive

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

I am not a guru, but let me relate my experiences:

1) if you are going to use windows.h it should be the first header, this is because the windows headers modify macros used by the RTL, I have read MS documentation on this (but cant remember where). This means that loadlib.c *needs* an in the module #ifdef to include windows.h as the first header. I vaguely remember specific problems with modules that include <io.h>, so in writing a Lua library for windows the header order is impoortant.

2) One can argue that VC_EXTRALEAN WIN32LEAN_AND_MEAN STRICT should be on the compiler command line invocation not in the headers e/g


and these should be considered depending on what you are building
/D_WIN32_WINNT=0x0500 \
/D_MBCS  or not \


Alexander Gladysh wrote:
Or just include windows.h where it is needed in loadlib.c under #elif
defined(LUA_DL_DLL) and not in the luaconf.h file.
Works without problems for me.

Much better. windows.h is a serious kitchen-sink header.

Agreed.  #include <windows.h> has no business out in my public header chain.


I've expected that, at least, it would be framed by #if
defined(LUA_CORE) checks, but no, it goes right to public. Nasty.

Furthermore, I remember that including windows.h without extra defines
is a bad idea.

When I coded for Windows, I always used to do at least this:

#define NOMINMAX
#include <windows.h>

Much less hassle. (Especially without min and max defined as macroses.)

Also, this (outdated) article suggests there can be even more useful defines:

Perhaps some Win32 guru would enlighten us more?