Subject: bug#9960: Compiling Emacs trunk with MSVC

From: Eli Zaretskii <[email-masked]>
Date: Sat, 05 Nov 2011 15:22:52 +0200

> Date: Sat, 05 Nov 2011 06:54:39 -0600
> From: Christoph Scholtes <[email-masked]>
> CC: [email-masked], [email-masked]
> 
> I tried building with Visual Studio 2008 (Express Edition) and the build 
> fails:
> 
>          cl -I. -nologo -D_X86_=1 -c -Zl -Zp8 -W2 -Od -Gd -Zi 
> -DEMACSDEBUG -DENA
> BLE_CHECKING -DXASSERTS -I"D:/devel/emacs/libs/libXpm-3.5.8/include" 
> -I"D:/devel
> /emacs/libs/libXpm-3.5.8/src" 
> -I"D:/devel/emacs/libs/libpng-dev_1.4.3-1/include"
>   -I"D:/devel/emacs/libs/zlib-dev_1.2.5-2/include" 
> -I"D:/devel/emacs/libs/giflib-
> 4.1.4-1/include" -I"D:/devel/emacs/libs/jpeg-6b-4/include" 
> -I"D:/devel/emacs/lib
> s/tiff-3.8.2-1/include" -I"D:/devel/emacs/libs/gnutls-2.10.1/include" 
> -DHAVE_CON
> FIG_H=1 -I. -I../nt/inc -I../src -Foobj/i386\ md5.c sha1.c sha256.c 
> sha512.c fil
> emode.c
> md5.c
> md5.c(259) : warning C4116: unnamed type definition in parentheses
> sha1.c
> sha1.c(74) : error C2054: expected '(' to follow 'inline'
> sha1.c(75) : error C2085: 'set_uint32' : not in formal parameter list
> sha1.c(75) : error C2143: syntax error : missing ';' before '{'
> sha1.c(246) : warning C4116: unnamed type definition in parentheses
> sha256.c
> sha256.c(93) : error C2054: expected '(' to follow 'inline'
> sha256.c(94) : error C2085: 'set_uint32' : not in formal parameter list
> sha256.c(94) : error C2143: syntax error : missing ';' before '{'
> sha256.c(378) : warning C4116: unnamed type definition in parentheses
> 
> [...] (more errors after this)
> 
> This is caused by `inline' keyword, which should be `__inline' for MSVC. 
> I don't see any place where this would be defined for the W32 build. Am 
> I missing something?

Does this patch give good results?

=== modified file 'nt/config.nt'
--- nt/config.nt	2011-10-31 02:25:01 +0000
+++ nt/config.nt	2011-11-05 13:21:58 +0000
@@ -328,9 +328,13 @@ along with GNU Emacs.  If not, see <http
 
 /* Define to `__inline__' or `__inline' if that's what the C compiler
    calls it, or to nothing if 'inline' is not supported under any name.  */
+#ifdef __GNUC__
 #ifndef __cplusplus
 #undef inline
 #endif
+#else  /* MSVC */
+#define inline __inline
+#endif
 
 /* Define to the equivalent of the C99 'restrict' keyword, or to
    nothing if this is not supported.  Do not define if restrict is