I've revisited building libspectrum (current SVN revision 4116) under Win32. I'm using Cygwin for the initial autoconf setup and header generation, then switching to a native Visual Studio project with a hand-tuned config.h
I'm using VC6 to reduce Cygwin runtime dependencies and so I can link with the common DLL version of the CRT (MSVCRT.DLL). I've also been building with VS2005, as the compilers included with VS2003-2008 have a similar feature set (usually behind gcc4 though). I've limited my suggested changes to what's needed for the later VC++ versions.
I've attached a patch and included details of the changes below.
Executable scripts with CRLF line endings choke Cygwin, and configure.in also has issues with CRs in the multi-line AC_OUTPUT when it's split into separate file names. Properties of the following need changing from native to LF in SubVersion:
That's the bare minimum I needed to get it to work, though additional files would benefit from the same change. Currently, libspectrum.h will be generated with a mix of LF and CRLF endings, since other parts of it still have native endings.
dll.c has switch(ul_reason_for_call) but the parameter name is just 'reason'
WIN32_DLL [__declspec(dllexport)] should be before the return type in declarations, rather than between return type and function name. The files affected are:
myglib/ghash.c:257 uses uint32_t in g_str_hash() on line 257, even if HAVE_STDINT_H isn't defined. I had to change it to libspectrum_dword instead.
warajevo_read.c:588 defines 'last_block' mid-scope, which I think might be valid in newer C standards (and certainly works with gcc4), but doesn't work with either version of VC++ that I tried.
M_LN2 (used by tzx_read.c) isn't defined in math.h under VC6, and requires _USE_MATH_DEFINES to be defined before including math.h to be present under VC2003 and later. I've added a conditional define to internals.h, but it could be done more thoroughly from configure.in if preferred.
VS6 doesn't support long long so __int64 is needed instead. I've not included the following change, which would need to be incorporated into the typedef section of make-perl.c.
#if defined(_MSC_VER) && _MSC_VER <= 1200
typedef unsigned __int64 libspectrum_qword;
typedef signed __int64 libspectrum_signed_qword;
typedef unsigned long long libspectrum_qword;
typedef signed long long libspectrum_signed_qword;
Log in to post a comment.