[quake3] first win64 patch
Ludwig Nussel
ludwig.nussel at suse.de
Sun Feb 19 06:43:11 EST 2006
Shane Isley wrote:
> I've a process that is doing a hourly Win32 build from the head.
> http://www.promode.org/files/ioq3.zip
> I believe zakk wanted it linked on icculus.org/quake3
> Anyhow commit 550 broke my Win32 build (I'm using VS 2005 and also
> vcbuild.exe).
> <inttypes.h> was the problem, in that Windows or MSVC do not come with it.
> I began fixing my problen by adding my cygwin version of inttypes.h, but
> it depended on another header and so on and so forth.
>
> So it ended up simpler to do this:
>
> Index: q_shared.h
> ===================================================================
> --- q_shared.h (revision 553)
> +++ q_shared.h (working copy)
> @@ -104,7 +104,7 @@
>
> #ifdef Q3_VM
> typedef int intptr_t;
> -#else
> +#elif !WIN32
> #include <inttypes.h>
> #endif
I assume cygwin/wingw32 have inttypes.h so I guess we need to use
_MSC_VER here
> Index: vm.c
> ===================================================================
> --- vm.c (revision 553)
> +++ vm.c (working copy)
> @@ -886,6 +886,11 @@
> f = fopen("syscalls.log", "w" );
> }
> callnum++;
> +#ifndef WIN32
> fprintf(f, "%i: %"PRIiPTR" (%i) = %i %i %i %i\n", callnum,
> (intptr_t)(args - (int *)currentVM->dataBase),
> args[0], args[1], args[2], args[3], args[4] );
> +#else
> + fprintf(f, "%i: %li (%i) = %i %i %i %i\n", callnum, (intptr_t)(args
> - (int *)currentVM->dataBase),
> + args[0], args[1], args[2], args[3], args[4] );
> +#endif
> }
>
> I had to also change the printf(). The compiler kept bombing with
> regards to the argument type (PRIiPTR or li) being outside the quotes"".
According to the header it's C99. It's the format specifier for
intptr_t. intptr_t is not long on 64bit Windows so you can't use
%li. Does MSVC have intptr_t but not PRIiPTR?
If so maybe a scary construct like the following helps:
Index: code/qcommon/q_shared.h
===================================================================
--- code/qcommon/q_shared.h (Revision 553)
+++ code/qcommon/q_shared.h (Arbeitskopie)
@@ -105,7 +105,20 @@
#ifdef Q3_VM
typedef int intptr_t;
#else
-#include <inttypes.h>
+# if !defined( _MSC_VER )
+# include <inttypes.h>
+# endif
+# ifndef PRIiPTR
+# if __WORDSIZE == 64
+# if defined( _MSC_VER )
+# define PRIiPTR "lli"
+# else
+# define PRIiPTR "li"
+# endif
+# else
+# define PRIiPTR "i"
+# endif
+# endif
#endif
typedef unsigned char byte;
cu
Ludwig
--
(o_ Ludwig Nussel
//\ SUSE LINUX Products GmbH, Development
V_/_ http://www.suse.de/
More information about the quake3
mailing list