Commit 06284335 authored by Tim Peters's avatar Tim Peters

Some help for SF 614770: MSVC 7.0 compiler support

This changes sys.version under Microsoft builds to include the MS compiler
version number (_MSC_VER).  Since VC 6 and VC 7 are apparently
incompatible, and both can be installed on a single box, distutils needs
some way to figure out which version of MSVC a given Python was compiled
under.

As also suggested by MvL, got rid of #ifdef'ery for the defunct _M_ALPHA
target.

Bugfix candidate?  Hard to say.  As far as I'm concerned, VC 7 wasn't
a supported platform in the 2.2 line.  If somebody thinks it should be,
they can do the work.
parent 01c04013
...@@ -61,6 +61,28 @@ MS_CORE_DLL. ...@@ -61,6 +61,28 @@ MS_CORE_DLL.
/* Microsoft C defines _MSC_VER */ /* Microsoft C defines _MSC_VER */
#ifdef _MSC_VER #ifdef _MSC_VER
/* We want COMPILER to expand to a string containing _MSC_VER's *value*.
* This is horridly tricky, because the stringization operator only works
* on macro arguments, and doesn't evaluate macros passed *as* arguments.
* Attempts simpler than the following appear doomed to produce "_MSC_VER"
* literally in the string.
*/
#define _Py_PASTE_VERSION(SUFFIX) \
("[MSC v." _Py_STRINGIZE(_MSC_VER) " " SUFFIX "]")
/* e.g., this produces, after compile-time string catenation,
* ("[MSC v.1200 32 bit (Intel)]")
*
* _Py_STRINGIZE(_MSC_VER) expands to
* _Py_STRINGIZE1((_MSC_VER)) expands to
* _Py_STRINGIZE2(_MSC_VER) but as this call is the result of token-pasting
* it's scanned again for macros and so further expands to (under MSVC 6)
* _Py_STRINGIZE2(1200) which then expands to
* "1200"
*/
#define _Py_STRINGIZE(X) _Py_STRINGIZE1((X))
#define _Py_STRINGIZE1(X) _Py_STRINGIZE2 ## X
#define _Py_STRINGIZE2(X) #X
/* MSVC defines _WINxx to differentiate the windows platform types /* MSVC defines _WINxx to differentiate the windows platform types
Note that for compatibility reasons _WIN32 is defined on Win32 Note that for compatibility reasons _WIN32 is defined on Win32
...@@ -76,21 +98,17 @@ MS_CORE_DLL. ...@@ -76,21 +98,17 @@ MS_CORE_DLL.
/* set the COMPILER */ /* set the COMPILER */
#ifdef MS_WIN64 #ifdef MS_WIN64
#ifdef _M_IX86 #ifdef _M_IX86
#define COMPILER "[MSC 64 bit (Intel)]" #define COMPILER _Py_PASTE_VERSION("64 bit (Intel)"
#elif defined(_M_ALPHA)
#define COMPILER "[MSC 64 bit (Alpha)]"
#else #else
#define COMPILER "[MSC 64 bit (Unknown)]" #define COMPILER _Py_PASTE_VERSION("64 bit (Unknown)")
#endif #endif
#endif /* MS_WIN64 */ #endif /* MS_WIN64 */
#if defined(MS_WIN32) && !defined(MS_WIN64) #if defined(MS_WIN32) && !defined(MS_WIN64)
#ifdef _M_IX86 #ifdef _M_IX86
#define COMPILER "[MSC 32 bit (Intel)]" #define COMPILER _Py_PASTE_VERSION("32 bit (Intel)")
#elif defined(_M_ALPHA)
#define COMPILER "[MSC 32 bit (Alpha)]"
#else #else
#define COMPILER "[MSC (Unknown)]" #define COMPILER _Py_PASTE_VERSION("32 bit (Unknown)")
#endif #endif
#endif /* MS_WIN32 && !MS_WIN64 */ #endif /* MS_WIN32 && !MS_WIN64 */
...@@ -177,7 +195,7 @@ typedef int pid_t; ...@@ -177,7 +195,7 @@ typedef int pid_t;
# define LONG_LONG __int64 # define LONG_LONG __int64
#endif #endif
/* For Windows the Python core is in a DLL by default. Test /* For Windows the Python core is in a DLL by default. Test
Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
#if !defined(MS_NO_COREDLL) && !defined(Py_NO_ENABLE_SHARED) #if !defined(MS_NO_COREDLL) && !defined(Py_NO_ENABLE_SHARED)
# define Py_ENABLE_SHARED 1 /* standard symbol for shared library */ # define Py_ENABLE_SHARED 1 /* standard symbol for shared library */
...@@ -196,7 +214,7 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ ...@@ -196,7 +214,7 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
#ifdef MS_COREDLL #ifdef MS_COREDLL
# ifndef Py_BUILD_CORE /* not building the core - must be an ext */ # ifndef Py_BUILD_CORE /* not building the core - must be an ext */
# if defined(_MSC_VER) # if defined(_MSC_VER)
/* So MSVC users need not specify the .lib file in /* So MSVC users need not specify the .lib file in
their Makefile (other compilers are generally their Makefile (other compilers are generally
taken care of by distutils.) */ taken care of by distutils.) */
# ifdef _DEBUG # ifdef _DEBUG
...@@ -227,16 +245,11 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ ...@@ -227,16 +245,11 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
#elif defined(MS_WIN32) #elif defined(MS_WIN32)
# define PLATFORM "win32" # define PLATFORM "win32"
# define HAVE_LARGEFILE_SUPPORT # define HAVE_LARGEFILE_SUPPORT
# ifdef _M_ALPHA # define SIZEOF_VOID_P 4
# define SIZEOF_VOID_P 8 # define SIZEOF_TIME_T 4
# define SIZEOF_TIME_T 8 # define SIZEOF_OFF_T 4
# else # define SIZEOF_FPOS_T 8
# define SIZEOF_VOID_P 4 # define SIZEOF_HKEY 4
# define SIZEOF_TIME_T 4
# define SIZEOF_OFF_T 4
# define SIZEOF_FPOS_T 8
# define SIZEOF_HKEY 4
# endif
#endif #endif
#ifdef _DEBUG #ifdef _DEBUG
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment