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.
i.e.
<windows.h>
<lua.h>

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

/DSTRICT=1 /DWIN32_LEAN_AND_MEAN=1 /DVC_EXTRALEAN=1 /D_CRT_SECURE_NO_DEPRECATE

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


DB


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.

Indeed.

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 WIN32_LEAN_AND_MEAN
#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:

http://support.microsoft.com/kb/166474

Perhaps some Win32 guru would enlighten us more?

Alexander.