Subject: Re: bug#9960: Compiling Emacs trunk with MSVC

From: Eli Zaretskii <[email-masked]>
Date: Sat, 05 Nov 2011 23:27:44 +0200

> From: Christoph Scholtes <[email-masked]>
> Cc: [email-masked],  [email-masked]
> Date: Sat, 05 Nov 2011 14:32:15 -0600
> 
> Christoph Scholtes <[email-masked]> 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;

That comes from Fabrice, assuming that removing `static' doesn't help.

Does it fail even if you take (1 << 3) in one more level of
parentheses?

What about an intermediate macro, as in

 #define FOO (1 << GCTYPEBITS)
 static int __declspec(align(FOO)) test = 1;

?

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

Thanks, please install this.

> Creating temacs.lib fails when linking with the following errors:
> 
> temacs2.lib(font.obj) : error LNK2019: unresolved external symbol _snprintf referenced in function _font_unparse_xlfd

Does this go away if you add "#define snprintf _snprintf" to
src/s/ms-w32.h, for MSVC only?

> 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

These are because xdisp.c defines window_box_right `inline'.  (This is
an optimized build, right? if not, does it mean that MSVC inlines
functions even for a non-optimized builds?)  I would suggest to make
that `inline' conditional on _MSC_VER being undefined.

> temacs2.lib(xdisp.obj) : error LNK2019: unresolved external symbol _strtoimax referenced in function _message_log_check_duplicate

Add "#define strtoimax _strtoi64" to src/s/ms-w32.h, conditioned on
_MSC_VER.

> libgnu.lib(strftime.obj) : error LNK2001: unresolved external symbol _tzname
> obj/i386/temacs.bin : fatal error LNK1120: 4 unresolved externals

Make this (from src/s/ms-w32.h):

  #if !defined (_MSC_VER) || (_MSC_VER < 1400)
  #define tzname    _tzname

be defined unconditionally.  (But leave the "utime" part under the
same condition it is today.)