GNU bug report logs - #9960
Compiling Emacs trunk with MSVC

Previous Next

Packages: emacs, w32;

Reported by: Eli Zaretskii <eliz <at> gnu.org>

Date: Sat, 5 Nov 2011 11:24:02 UTC

Severity: normal

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Christoph Scholtes <cschol2112 <at> googlemail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: fabrice.popineau <at> supelec.fr, 9960 <at> debbugs.gnu.org
Subject: bug#9960: Compiling Emacs trunk with MSVC
Date: Sat, 05 Nov 2011 14:32:15 -0600
Christoph Scholtes <cschol2112 <at> googlemail.com> writes:

> Then we get to emacs.c:
> emacs.c(537) : error C2059: syntax error : '<<'
> emacs.c(537) : error C2059: syntax error : 'constant'
> emacs.c(537) : error C2059: syntax error : ')'

cl.exe does not like the shift operator in this statement:

static int __declspec(align(1 << 3)) test = 1;

whereas 

static int __declspec(align(8)) test = 1;

works. 

The above is a simple test case to confirm the fault is in this
code in lisp.h, l.172:

#  elif defined(_MSC_VER)
#   define DECL_ALIGN(type, var) \
     type __declspec(align(1 << GCTYPEBITS)) var


Other errors are due to missing definitions in stdint.h. The following
patch fixes this (64bit support added for completeness):

=== modified file 'nt/inc/stdint.h'
--- nt/inc/stdint.h	2011-06-07 12:34:09 +0000
+++ nt/inc/stdint.h	2011-11-05 20:03:50 +0000
@@ -27,21 +27,37 @@
 /* Minimum definitions to allow compilation with tool chains where
    stdint.h is not available, e.g. Microsoft Visual Studio.  */
 
-typedef unsigned int uint32_t;
-#define INT32_MAX 2147483647
-/* "i64" is the non-standard suffix used by MSVC for 64-bit constants.  */
-#define INT64_MAX 9223372036854775807i64
-
 #ifdef _WIN64
   typedef __int64 intptr_t;
+#define UINT64_MAX 18446744073709551616
+#define UINT64_MIN 0
+/* "i64" is the non-standard suffix used by MSVC for 64-bit constants.  */
+#define INT64_MAX 9223372036854775807i64
+#define INT64_MIN (~INT64_MAX)
 #define INTPTR_MAX INT64_MAX
+#define UINTMAX_MAX UINT64_MAX
+#define UINTMAX_MIN UINT64_MIN
+#define INTMAX_MAX INT64_MAX
+#define INTMAX_MIN INT64_MIN
 #else
   typedef int intptr_t;
+typedef unsigned int uint32_t;
+#define UINT32_MAX 4294967296
+#define UINT32_MIN 0
+#define INT32_MAX 2147483647
+#define INT32_MIN (~INT32_MAX)
 #define INTPTR_MAX INT32_MAX
+#define UINTMAX_MAX UINT32_MAX
+#define UINTMAX_MIN UINT32_MIN
+#define INTMAX_MAX INT32_MAX
+#define INTMAX_MIN INT32_MIN
 #endif
 
 #define uintmax_t unsigned __int64
+#define intmax_t __int64
 #define PTRDIFF_MAX INTPTR_MAX
+
+
 
 #endif	/* !__GNUC__ */


There are tons of warnings, but everything compiles from then
on. 

Creating temacs.lib fails when linking with the following errors:

temacs2.lib(font.obj) : error LNK2019: unresolved external symbol _snprintf refe
renced in function _font_unparse_xlfd
temacs2.lib(fringe.obj) : error LNK2019: unresolved external symbol _window_box_
right referenced in function _draw_fringe_bitmap_1
temacs2.lib(w32term.obj) : error LNK2001: unresolved external symbol _window_box
_right
temacs2.lib(xdisp.obj) : error LNK2019: unresolved external symbol _strtoimax re
ferenced in function _message_log_check_duplicate
libgnu.lib(strftime.obj) : error LNK2001: unresolved external symbol _tzname
obj/i386/temacs.bin : fatal error LNK1120: 4 unresolved externals




This bug report was last modified 13 years and 61 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.