[PATCH] Fix to support old version of crtdefs.h

HAYASHI Kentaro hayashi at clear-code.com
Thu Aug 2 03:31:59 UTC 2012


Hi,

I attached a patch for fixing build problem (_CRT_SECURE_NO_DEPRECATE)
 with Visual Studio 2005 Express.

The problem is that old version of crtdefs.h uses _CRT_SECURE_NO_DEPRECATE 
(instead of _CRT_SECURE_NO_WARNINGS) for eliminating the warnings.

see: http://social.msdn.microsoft.com/forums/en-US/vcgeneral/thread/3373dd77-ed73-44a6-a52c-53dfd95099ac/

The purpose of this patch is supporting old version of crtdefs.h 
by adding definition about _CRT_SECURE_NO_DEPRECATE.

As a result, nmake build process succeeds with Visual Studio 2005 Express under Wine.

NOTE:
* I used Wine to setup old version of crtdefs.h.
* I confirmed that VS2005 Express and VS2005 Express SP1 uses old version of crtdefs.h.
  (It seems that VS2005 Express SP1 with latest hotfix use newer version of crtdefs.h)
* I confirmed that this patch does not affects build process 
  even if newer version of crtdefs.h is used.

I hope that this patch will be applied to nginx mainstream.


Index: src/os/win32/ngx_win32_config.h
===================================================================
--- src/os/win32/ngx_win32_config.h	(revision 4778)
+++ src/os/win32/ngx_win32_config.h	(working copy)
@@ -19,6 +19,11 @@
 /* enable getenv() and gmtime() in msvc8 */
 #define _CRT_SECURE_NO_WARNINGS
 
+/* support old version of crtdefs.h in msvc8 */
+#if (_MSC_VER == 1400)
+#define _CRT_SECURE_NO_DEPRECATE
+#endif
+
 /*
  * we need to include <windows.h> explicitly before <winsock2.h> because
  * the warning 4201 is enabled in <windows.h>


I wrote how to reproduce the problem and details.

Steps to reproduce the problem:

1) Install Wine 1.4 on Ubuntu 12.04 LTS.
 
 % sudo apt-get install wine winetricks

2) Setup WINE related environment variables.

 % export WINPREFIX=$HOME/.win32en
 % export WINEARCH=win32

3) Install MFC42 and .NET 2.0 under Wine.

 % winetricks --no-isolate -q mfc42 dotnet20

4) Install Visual Studio 2005 Express under Wine.
 
 % winetricks --no-isolate -q vc2005express

5) Install Windows SDK under Wine.
 
 % winetricks --no-isolate -q psdkwin7

6) Make symlink cl and rc to pass auto/configure compiler
check (this is ad-hoc way, but just works).

 % cd $HOME/.wine32en/drive_c/Program Files/Microsoft Visual Studio 8/VC/bin
 % ln -sf cl.exe cl
 % ln -sf rc.exe rc

7) Generate Makefile by executing following command to build minimum
nginx binary.

 % auto/configure --crossbuild=win32 --with-cc=cl \
   --without-http_rewrite_module --without-http_gzip_module

8) Execute nmake.exe

 % nmake.exe

What happened:

Make process was failed. Warning is treated as error:

---Start Here---
	cl -c -O2  -W4 -WX -nologo -MT -Yungx_config.h -Fpobjs/ngx_config.pch -I src/core  -I src/event  -I src/event/modules  -I src/os/win32  -I objs  -I src/http  -I src/http/modules  -I src/mail  -Foobjs/src/core/nginx.obj  src/core/nginx.c
fixme:file:NeedCurrentDirectoryForExePathW (L"cl"): partial stub
nginx.c
src/core/nginx.c(424) : error C2220: warning treated as error - no 'object' file generated
src/core/nginx.c(424) : warning C4996: 'getenv' was declared deprecated
        C:\Program Files\Microsoft Visual Studio 8\VC\include\stdlib.h(483) : see declaration of 'getenv'
        Message: 'This function or variable may be unsafe. Consider using _dupenv_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 8\VC\bin\cl.EXE"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 8\VC\bin\nmake.exe"' : return code '0x2'
Stop.
---End Here---

Thanks.

-- 
HAYASHI Kentaro <hayashi at clear-code.com>



More information about the nginx-devel mailing list