I would like to ask you a technical question regarding python module compilation for python 2.7.1.
I want to compile mod_python <https://app.box.com/s/orsffo3t4g6h9ftkq6p1>library for Apache 2.2 and py2.7 <https://www.python.org/downloads/> on Win32 in order to use it for psp - py scripts that i have written. I tried to compile it using VS 2008 (VC++) and unfortunately i get an error on pyconfig.h (Py2.7/include) error C2632: int followed by int is illegal. This problem occurs when i try to run the bat file that exists on mod_python/dist folder. Any idea or suggestion what should i do in order to run it on Win 7 Pro (win 32) environment and produce the final apache executable module (.so). For your better assistance, i attach you the necessary files and error_log (ouput that i get during compilation process). I have posted the same question here <http://stackoverflow.com/questions/37696936/vc-compilation-error-in-pyconfig-h-vs-2008>, but unfortunately i had had no luck! Additionally i give you the compilation instructions that i follow (used also MinGW-w64 and get the same error) in order to produce the final output! Compiling Open a command prompt with VS2008 support. The easiest way to do this is to use "Start | All Programs | Microsoft Visual Studio 2008 | Visual Studio Tools | Visual Studio 2008 Command Prompt". (This puts the VS2008 binaries in the path and sets up the lib/include environmental variables for the Platform SDK.) 1.cd to the mod_python\dist folder. 2.Tell mod_python where Apache is: set APACHESRC=C:\Apache 3. Run build_installer.bat. If it succeeds, an installer.exe will be created in a subfolder. Run that install the module. Kind Regards Kostas Asimakopoulos
#ifndef __GETOPT_H__ /** * DISCLAIMER * This file is part of the mingw-w64 runtime package. * * The mingw-w64 runtime package and its code is distributed in the hope that it * will be useful but WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESSED OR * IMPLIED ARE HEREBY DISCLAIMED. This includes but is not limited to * warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ /* * Copyright (c) 2002 Todd C. Miller <todd.mil...@courtesan.com> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Sponsored in part by the Defense Advanced Research Projects * Agency (DARPA) and Air Force Research Laboratory, Air Force * Materiel Command, USAF, under agreement number F39502-99-1-0512. */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Dieter Baron and Thomas Klausner. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ //#pragma warning(disable:4996); #pragma warning(disable:4996) #define _CRT_SECURE_NO_WARNINGS #define __GETOPT_H__ /* All the headers include this file. */ #include <crtdefs.h> #include <errno.h> #include <stdlib.h> #include <string.h> #include <stdarg.h> #include <stdio.h> #include <windows.h> #ifdef __cplusplus extern "C" { #endif #define REPLACE_GETOPT /* use this getopt as the system getopt(3) */ #ifdef REPLACE_GETOPT int opterr = 1; /* if error message should be printed */ int optind = 1; /* index into parent argv vector */ int optopt = '?'; /* character checked for validity */ #undef optreset /* see getopt.h */ #define optreset __mingw_optreset int optreset; /* reset getopt */ char *optarg; /* argument associated with option */ #endif //extern int optind; /* index of first non-option in argv */ //extern int optopt; /* single option character, as parsed */ //extern int opterr; /* flag to enable built-in diagnostics... */ // /* (user may set to zero, to suppress) */ // //extern char *optarg; /* pointer to argument of current option */ #define PRINT_ERROR ((opterr) && (*options != ':')) #define FLAG_PERMUTE 0x01 /* permute non-options to the end of argv */ #define FLAG_ALLARGS 0x02 /* treat non-options as args to option "-1" */ #define FLAG_LONGONLY 0x04 /* operate as getopt_long_only */ /* return values */ #define BADCH (int)'?' #define BADARG ((*options == ':') ? (int)':' : (int)'?') #define INORDER (int)1 #ifndef __CYGWIN__ #define __progname __argv[0] #else extern char __declspec(dllimport) *__progname; #endif #ifdef __CYGWIN__ static char EMSG[] = ""; #else #define EMSG "" #endif static int getopt_internal(int, char * const *, const char *, const struct option *, int *, int); static int parse_long_options(char * const *, const char *, const struct option *, int *, int); static int gcd(int, int); static void permute_args(int, int, int, char * const *); static char *place = EMSG; /* option letter processing */ /* XXX: set optreset to 1 rather than these two */ static int nonopt_start = -1; /* first non option argument (for permute) */ static int nonopt_end = -1; /* first option after non options (for permute) */ /* Error messages */ static const char recargchar[] = "option requires an argument -- %c"; static const char recargstring[] = "option requires an argument -- %s"; static const char ambig[] = "ambiguous option -- %.*s"; static const char noarg[] = "option doesn't take an argument -- %.*s"; static const char illoptchar[] = "unknown option -- %c"; static const char illoptstring[] = "unknown option -- %s"; static void _vwarnx(const char *fmt,va_list ap) { (void)fprintf(stderr,"%s: ",__progname); if (fmt != NULL) (void)vfprintf(stderr,fmt,ap); (void)fprintf(stderr,"\n"); } static void warnx(const char *fmt,...) { va_list ap; va_start(ap,fmt); _vwarnx(fmt,ap); va_end(ap); } /* * Compute the greatest common divisor of a and b. */ static int gcd(int a, int b) { int c; c = a % b; while (c != 0) { a = b; b = c; c = a % b; } return (b); } /* * Exchange the block from nonopt_start to nonopt_end with the block * from nonopt_end to opt_end (keeping the same order of arguments * in each block). */ static void permute_args(int panonopt_start, int panonopt_end, int opt_end, char * const *nargv) { int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos; char *swap; /* * compute lengths of blocks and number and size of cycles */ nnonopts = panonopt_end - panonopt_start; nopts = opt_end - panonopt_end; ncycle = gcd(nnonopts, nopts); cyclelen = (opt_end - panonopt_start) / ncycle; for (i = 0; i < ncycle; i++) { cstart = panonopt_end+i; pos = cstart; for (j = 0; j < cyclelen; j++) { if (pos >= panonopt_end) pos -= nnonopts; else pos += nopts; swap = nargv[pos]; /* LINTED const cast */ ((char **) nargv)[pos] = nargv[cstart]; /* LINTED const cast */ ((char **)nargv)[cstart] = swap; } } } #ifdef REPLACE_GETOPT /* * getopt -- * Parse argc/argv argument vector. * * [eventually this will replace the BSD getopt] */ int getopt(int nargc, char * const *nargv, const char *options) { /* * We don't pass FLAG_PERMUTE to getopt_internal() since * the BSD getopt(3) (unlike GNU) has never done this. * * Furthermore, since many privileged programs call getopt() * before dropping privileges it makes sense to keep things * as simple (and bug-free) as possible. */ return (getopt_internal(nargc, nargv, options, NULL, NULL, 0)); } #endif /* REPLACE_GETOPT */ //extern int getopt(int nargc, char * const *nargv, const char *options); #ifdef _BSD_SOURCE /* * BSD adds the non-standard `optreset' feature, for reinitialisation * of `getopt' parsing. We support this feature, for applications which * proclaim their BSD heritage, before including this header; however, * to maintain portability, developers are advised to avoid it. */ # define optreset __mingw_optreset extern int optreset; #endif #ifdef __cplusplus } #endif /* * POSIX requires the `getopt' API to be specified in `unistd.h'; * thus, `unistd.h' includes this header. However, we do not want * to expose the `getopt_long' or `getopt_long_only' APIs, when * included in this manner. Thus, close the standard __GETOPT_H__ * declarations block, and open an additional __GETOPT_LONG_H__ * specific block, only when *not* __UNISTD_H_SOURCED__, in which * to declare the extended API. */ #endif /* !defined(__GETOPT_H__) */ #if !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__) #define __GETOPT_LONG_H__ #ifdef __cplusplus extern "C" { #endif struct option /* specification for a long form option... */ { const char *name; /* option name, without leading hyphens */ int has_arg; /* does it take an argument? */ int *flag; /* where to save its status, or NULL */ int val; /* its associated status value */ }; enum /* permitted values for its `has_arg' field... */ { no_argument = 0, /* option never takes an argument */ required_argument, /* option always requires an argument */ optional_argument /* option may take an argument */ }; /* * parse_long_options -- * Parse long options in argc/argv argument vector. * Returns -1 if short_too is set and the option does not match long_options. */ static int parse_long_options(char * const *nargv, const char *options, const struct option *long_options, int *idx, int short_too) { char *current_argv, *has_equal; size_t current_argv_len; int i, ambiguous, match; #define IDENTICAL_INTERPRETATION(_x, _y) \ (long_options[(_x)].has_arg == long_options[(_y)].has_arg && \ long_options[(_x)].flag == long_options[(_y)].flag && \ long_options[(_x)].val == long_options[(_y)].val) current_argv = place; match = -1; ambiguous = 0; optind++; if ((has_equal = strchr(current_argv, '=')) != NULL) { /* argument found (--option=arg) */ current_argv_len = has_equal - current_argv; has_equal++; } else current_argv_len = strlen(current_argv); for (i = 0; long_options[i].name; i++) { /* find matching long option */ if (strncmp(current_argv, long_options[i].name, current_argv_len)) continue; if (strlen(long_options[i].name) == current_argv_len) { /* exact match */ match = i; ambiguous = 0; break; } /* * If this is a known short option, don't allow * a partial match of a single character. */ if (short_too && current_argv_len == 1) continue; if (match == -1) /* partial match */ match = i; else if (!IDENTICAL_INTERPRETATION(i, match)) ambiguous = 1; } if (ambiguous) { /* ambiguous abbreviation */ if (PRINT_ERROR) warnx(ambig, (int)current_argv_len, current_argv); optopt = 0; return (BADCH); } if (match != -1) { /* option found */ if (long_options[match].has_arg == no_argument && has_equal) { if (PRINT_ERROR) warnx(noarg, (int)current_argv_len, current_argv); /* * XXX: GNU sets optopt to val regardless of flag */ if (long_options[match].flag == NULL) optopt = long_options[match].val; else optopt = 0; return (BADARG); } if (long_options[match].has_arg == required_argument || long_options[match].has_arg == optional_argument) { if (has_equal) optarg = has_equal; else if (long_options[match].has_arg == required_argument) { /* * optional argument doesn't use next nargv */ optarg = nargv[optind++]; } } if ((long_options[match].has_arg == required_argument) && (optarg == NULL)) { /* * Missing argument; leading ':' indicates no error * should be generated. */ if (PRINT_ERROR) warnx(recargstring, current_argv); /* * XXX: GNU sets optopt to val regardless of flag */ if (long_options[match].flag == NULL) optopt = long_options[match].val; else optopt = 0; --optind; return (BADARG); } } else { /* unknown option */ if (short_too) { --optind; return (-1); } if (PRINT_ERROR) warnx(illoptstring, current_argv); optopt = 0; return (BADCH); } if (idx) *idx = match; if (long_options[match].flag) { *long_options[match].flag = long_options[match].val; return (0); } else return (long_options[match].val); #undef IDENTICAL_INTERPRETATION } /* * getopt_internal -- * Parse argc/argv argument vector. Called by user level routines. */ static int getopt_internal(int nargc, char * const *nargv, const char *options, const struct option *long_options, int *idx, int flags) { char *oli; /* option letter list index */ int optchar, short_too; static int posixly_correct = -1; if (options == NULL) return (-1); /* * XXX Some GNU programs (like cvs) set optind to 0 instead of * XXX using optreset. Work around this braindamage. */ if (optind == 0) optind = optreset = 1; /* * Disable GNU extensions if POSIXLY_CORRECT is set or options * string begins with a '+'. * * CV, 2009-12-14: Check POSIXLY_CORRECT anew if optind == 0 or * optreset != 0 for GNU compatibility. */ if (posixly_correct == -1 || optreset != 0) posixly_correct = (getenv("POSIXLY_CORRECT") != NULL); if (*options == '-') flags |= FLAG_ALLARGS; else if (posixly_correct || *options == '+') flags &= ~FLAG_PERMUTE; if (*options == '+' || *options == '-') options++; optarg = NULL; if (optreset) nonopt_start = nonopt_end = -1; start: if (optreset || !*place) { /* update scanning pointer */ optreset = 0; if (optind >= nargc) { /* end of argument vector */ place = EMSG; if (nonopt_end != -1) { /* do permutation, if we have to */ permute_args(nonopt_start, nonopt_end, optind, nargv); optind -= nonopt_end - nonopt_start; } else if (nonopt_start != -1) { /* * If we skipped non-options, set optind * to the first of them. */ optind = nonopt_start; } nonopt_start = nonopt_end = -1; return (-1); } if (*(place = nargv[optind]) != '-' || (place[1] == '\0' && strchr(options, '-') == NULL)) { place = EMSG; /* found non-option */ if (flags & FLAG_ALLARGS) { /* * GNU extension: * return non-option as argument to option 1 */ optarg = nargv[optind++]; return (INORDER); } if (!(flags & FLAG_PERMUTE)) { /* * If no permutation wanted, stop parsing * at first non-option. */ return (-1); } /* do permutation */ if (nonopt_start == -1) nonopt_start = optind; else if (nonopt_end != -1) { permute_args(nonopt_start, nonopt_end, optind, nargv); nonopt_start = optind - (nonopt_end - nonopt_start); nonopt_end = -1; } optind++; /* process next argument */ goto start; } if (nonopt_start != -1 && nonopt_end == -1) nonopt_end = optind; /* * If we have "-" do nothing, if "--" we are done. */ if (place[1] != '\0' && *++place == '-' && place[1] == '\0') { optind++; place = EMSG; /* * We found an option (--), so if we skipped * non-options, we have to permute. */ if (nonopt_end != -1) { permute_args(nonopt_start, nonopt_end, optind, nargv); optind -= nonopt_end - nonopt_start; } nonopt_start = nonopt_end = -1; return (-1); } } /* * Check long options if: * 1) we were passed some * 2) the arg is not just "-" * 3) either the arg starts with -- we are getopt_long_only() */ if (long_options != NULL && place != nargv[optind] && (*place == '-' || (flags & FLAG_LONGONLY))) { short_too = 0; if (*place == '-') place++; /* --foo long option */ else if (*place != ':' && strchr(options, *place) != NULL) short_too = 1; /* could be short option too */ optchar = parse_long_options(nargv, options, long_options, idx, short_too); if (optchar != -1) { place = EMSG; return (optchar); } } if ((optchar = (int)*place++) == (int)':' || (optchar == (int)'-' && *place != '\0') || (oli = (char*)strchr(options, optchar)) == NULL) { /* * If the user specified "-" and '-' isn't listed in * options, return -1 (non-option) as per POSIX. * Otherwise, it is an unknown option character (or ':'). */ if (optchar == (int)'-' && *place == '\0') return (-1); if (!*place) ++optind; if (PRINT_ERROR) warnx(illoptchar, optchar); optopt = optchar; return (BADCH); } if (long_options != NULL && optchar == 'W' && oli[1] == ';') { /* -W long-option */ if (*place) /* no space */ /* NOTHING */; else if (++optind >= nargc) { /* no arg */ place = EMSG; if (PRINT_ERROR) warnx(recargchar, optchar); optopt = optchar; return (BADARG); } else /* white space */ place = nargv[optind]; optchar = parse_long_options(nargv, options, long_options, idx, 0); place = EMSG; return (optchar); } if (*++oli != ':') { /* doesn't take argument */ if (!*place) ++optind; } else { /* takes (optional) argument */ optarg = NULL; if (*place) /* no white space */ optarg = place; else if (oli[1] != ':') { /* arg not optional */ if (++optind >= nargc) { /* no arg */ place = EMSG; if (PRINT_ERROR) warnx(recargchar, optchar); optopt = optchar; return (BADARG); } else optarg = nargv[optind]; } place = EMSG; ++optind; } /* dump back option letter */ return (optchar); } /* * getopt_long -- * Parse argc/argv argument vector. */ int getopt_long(int nargc, char * const *nargv, const char *options, const struct option *long_options, int *idx) { return (getopt_internal(nargc, nargv, options, long_options, idx, FLAG_PERMUTE)); } /* * getopt_long_only -- * Parse argc/argv argument vector. */ int getopt_long_only(int nargc, char * const *nargv, const char *options, const struct option *long_options, int *idx) { return (getopt_internal(nargc, nargv, options, long_options, idx, FLAG_PERMUTE|FLAG_LONGONLY)); } //extern int getopt_long(int nargc, char * const *nargv, const char *options, // const struct option *long_options, int *idx); //extern int getopt_long_only(int nargc, char * const *nargv, const char *options, // const struct option *long_options, int *idx); /* * Previous MinGW implementation had... */ #ifndef HAVE_DECL_GETOPT /* * ...for the long form API only; keep this for compatibility. */ # define HAVE_DECL_GETOPT 1 #endif #ifdef __cplusplus } #endif #endif /* !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__) */
#ifndef _UNISTD_H #define _UNISTD_H 1 /* This file intended to serve as a drop-in replacement for * unistd.h on Windows * Please add functionality as neeeded */ #include <stdlib.h> #include <io.h> #include <getopt.h> /* getopt at: https://gist.github.com/ashelly/7776712 */ #include <process.h> /* for getpid() and the exec..() family */ #include <direct.h> /* for _getcwd() and _chdir() */ #define srandom srand #define random rand /* Values for the second argument to access. These may be OR'd together. */ #define R_OK 4 /* Test for read permission. */ #define W_OK 2 /* Test for write permission. */ //#define X_OK 1 /* execute permission - unsupported in windows*/ #define F_OK 0 /* Test for existence. */ #define access _access #define dup2 _dup2 #define execve _execve #define ftruncate _chsize #define unlink _unlink #define fileno _fileno #define getcwd _getcwd #define chdir _chdir #define isatty _isatty #define lseek _lseek /* read, write, and close are NOT being #defined here, because while there are file handle specific versions for Windows, they probably don't work for sockets. You need to look at your app and consider whether to call e.g. closesocket(). */ #define ssize_t int #define STDIN_FILENO 0 #define STDOUT_FILENO 1 #define STDERR_FILENO 2 /* should be in some equivalent to <sys/types.h> */ typedef __int8 int8_t; typedef __int16 int16_t; typedef __int32 int32_t; typedef __int64 int64_t; typedef unsigned __int8 uint8_t; typedef unsigned __int16 uint16_t; typedef unsigned __int32 uint32_t; typedef unsigned __int64 uint64_t; #endif /* unistd.h */
mod_python_error.docx
Description: MS-Word 2007 document
#ifndef Py_CONFIG_H #define Py_CONFIG_H /* pyconfig.h. NOT Generated automatically by configure. This is a manually maintained version used for the Watcom, Borland and Microsoft Visual C++ compilers. It is a standard part of the Python distribution. WINDOWS DEFINES: The code specific to Windows should be wrapped around one of the following #defines MS_WIN64 - Code specific to the MS Win64 API MS_WIN32 - Code specific to the MS Win32 (and Win64) API (obsolete, this covers all supported APIs) MS_WINDOWS - Code specific to Windows, but all versions. MS_WINCE - Code specific to Windows CE Py_ENABLE_SHARED - Code if the Python core is built as a DLL. Also note that neither "_M_IX86" or "_MSC_VER" should be used for any purpose other than "Windows Intel x86 specific" and "Microsoft compiler specific". Therefore, these should be very rare. NOTE: The following symbols are deprecated: NT, USE_DL_EXPORT, USE_DL_IMPORT, DL_EXPORT, DL_IMPORT MS_CORE_DLL. WIN32 is still required for the locale module. */ #ifdef _WIN32_WCE #define MS_WINCE #endif /* Deprecated USE_DL_EXPORT macro - please use Py_BUILD_CORE */ #ifdef USE_DL_EXPORT # define Py_BUILD_CORE #endif /* USE_DL_EXPORT */ /* Visual Studio 2005 introduces deprecation warnings for "insecure" and POSIX functions. The insecure functions should be replaced by *_s versions (according to Microsoft); the POSIX functions by _* versions (which, according to Microsoft, would be ISO C conforming). Neither renaming is feasible, so we just silence the warnings. */ #ifndef _CRT_SECURE_NO_DEPRECATE #define _CRT_SECURE_NO_DEPRECATE 1 #endif #ifndef _CRT_NONSTDC_NO_DEPRECATE #define _CRT_NONSTDC_NO_DEPRECATE 1 #endif /* Windows CE does not have these */ #ifndef MS_WINCE #define HAVE_IO_H #define HAVE_SYS_UTIME_H #define HAVE_TEMPNAM #define HAVE_TMPFILE #define HAVE_TMPNAM #define HAVE_CLOCK #define HAVE_STRERROR #endif #ifdef HAVE_IO_H #include <io.h> #endif #define HAVE_HYPOT #define HAVE_STRFTIME #define DONT_HAVE_SIG_ALARM #define DONT_HAVE_SIG_PAUSE #define LONG_BIT 32 #define WORD_BIT 32 #define PREFIX "" #define EXEC_PREFIX "" #define MS_WIN32 /* only support win32 and greater. */ #define MS_WINDOWS #ifndef PYTHONPATH # define PYTHONPATH ".\\DLLs;.\\lib;.\\lib\\plat-win;.\\lib\\lib-tk" #endif #define NT_THREADS #define WITH_THREAD #ifndef NETSCAPE_PI #define USE_SOCKET #endif /* CE6 doesn't have strdup() but _strdup(). Assume the same for earlier versions. */ #if defined(MS_WINCE) # include <stdlib.h> # define strdup _strdup #endif #ifdef MS_WINCE /* Windows CE does not support environment variables */ #define getenv(v) (NULL) #define environ (NULL) #endif /* Compiler specific defines */ /* ------------------------------------------------------------------------*/ /* Microsoft C defines _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 Note that for compatibility reasons _WIN32 is defined on Win32 *and* on Win64. For the same reasons, in Python, MS_WIN32 is defined on Win32 *and* Win64. Win32 only code must therefore be guarded as follows: #if defined(MS_WIN32) && !defined(MS_WIN64) Some modules are disabled on Itanium processors, therefore we have MS_WINI64 set for those targets, otherwise MS_WINX64 */ #ifdef _WIN64 #define MS_WIN64 #endif /* set the COMPILER */ #ifdef MS_WIN64 #if defined(_M_IA64) #define COMPILER _Py_PASTE_VERSION("64 bit (Itanium)") #define MS_WINI64 #elif defined(_M_X64) || defined(_M_AMD64) #ifdef __INTEL_COMPILER #define COMPILER ("[ICC v." _Py_STRINGIZE(__INTEL_COMPILER) " 64 bit (amd64) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]") #else #define COMPILER _Py_PASTE_VERSION("64 bit (AMD64)") #endif /* __INTEL_COMPILER */ #define MS_WINX64 #else #define COMPILER _Py_PASTE_VERSION("64 bit (Unknown)") #endif #endif /* MS_WIN64 */ /* set the version macros for the windows headers */ #ifdef MS_WINX64 /* 64 bit only runs on XP or greater */ #define Py_WINVER _WIN32_WINNT_WINXP #define Py_NTDDI NTDDI_WINXP #else /* Python 2.6+ requires Windows 2000 or greater */ #ifdef _WIN32_WINNT_WIN2K #define Py_WINVER _WIN32_WINNT_WIN2K #else #define Py_WINVER 0x0500 #endif #define Py_NTDDI NTDDI_WIN2KSP4 #endif /* We only set these values when building Python - we don't want to force these values on extensions, as that will affect the prototypes and structures exposed in the Windows headers. Even when building Python, we allow a single source file to override this - they may need access to structures etc so it can optionally use new Windows features if it determines at runtime they are available. */ #if defined(Py_BUILD_CORE) || defined(Py_BUILD_CORE_MODULE) #ifndef NTDDI_VERSION #define NTDDI_VERSION Py_NTDDI #endif #ifndef WINVER #define WINVER Py_WINVER #endif #ifndef _WIN32_WINNT #define _WIN32_WINNT Py_WINVER #endif #endif /* _W64 is not defined for VC6 or eVC4 */ #ifndef _W64 #define _W64 #endif /* Define like size_t, omitting the "unsigned" */ #ifdef MS_WIN64 typedef __int64 ssize_t; #else typedef _W64 int ssize_t; #endif #define HAVE_SSIZE_T 1 #if defined(MS_WIN32) && !defined(MS_WIN64) #ifdef _M_IX86 #ifdef __INTEL_COMPILER #define COMPILER ("[ICC v." _Py_STRINGIZE(__INTEL_COMPILER) " 32 bit (Intel) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]") #else #define COMPILER _Py_PASTE_VERSION("32 bit (Intel)") #endif /* __INTEL_COMPILER */ #else #define COMPILER _Py_PASTE_VERSION("32 bit (Unknown)") #endif #endif /* MS_WIN32 && !MS_WIN64 */ typedef int pid_t; #include <float.h> #define Py_IS_NAN _isnan #define Py_IS_INFINITY(X) (!_finite(X) && !_isnan(X)) #define Py_IS_FINITE(X) _finite(X) #define copysign _copysign /* VS 2010 and above already defines hypot as _hypot */ #if _MSC_VER < 1600 #define hypot _hypot #endif #endif /* _MSC_VER */ /* define some ANSI types that are not defined in earlier Win headers */ #if defined(_MSC_VER) && _MSC_VER >= 1200 /* This file only exists in VC 6.0 or higher */ #include <basetsd.h> #endif /* ------------------------------------------------------------------------*/ /* The Borland compiler defines __BORLANDC__ */ /* XXX These defines are likely incomplete, but should be easy to fix. */ #ifdef __BORLANDC__ #define COMPILER "[Borland]" #ifdef _WIN32 /* tested with BCC 5.5 (__BORLANDC__ >= 0x0550) */ typedef int pid_t; /* BCC55 seems to understand __declspec(dllimport), it is used in its own header files (winnt.h, ...) - so we can do nothing and get the default*/ #undef HAVE_SYS_UTIME_H #define HAVE_UTIME_H #define HAVE_DIRENT_H /* rename a few functions for the Borland compiler */ #include <io.h> #define _chsize chsize #define _setmode setmode #else /* !_WIN32 */ #error "Only Win32 and later are supported" #endif /* !_WIN32 */ #endif /* BORLANDC */ /* ------------------------------------------------------------------------*/ /* egcs/gnu-win32 defines __GNUC__ and _WIN32 */ #if defined(__GNUC__) && defined(_WIN32) /* XXX These defines are likely incomplete, but should be easy to fix. They should be complete enough to build extension modules. */ /* Suggested by Rene Liebscher <r.liebsc...@gmx.de> to avoid a GCC 2.91.* bug that requires structure imports. More recent versions of the compiler don't exhibit this bug. */ #if (__GNUC__==2) && (__GNUC_MINOR__<=91) #warning "Please use an up-to-date version of gcc! (>2.91 recommended)" #endif #define COMPILER "[gcc]" #define hypot _hypot #define PY_LONG_LONG long long #define PY_LLONG_MIN LLONG_MIN #define PY_LLONG_MAX LLONG_MAX #define PY_ULLONG_MAX ULLONG_MAX #endif /* GNUC */ /* ------------------------------------------------------------------------*/ /* lcc-win32 defines __LCC__ */ #if defined(__LCC__) /* XXX These defines are likely incomplete, but should be easy to fix. They should be complete enough to build extension modules. */ #define COMPILER "[lcc-win32]" typedef int pid_t; /* __declspec() is supported here too - do nothing to get the defaults */ #endif /* LCC */ /* ------------------------------------------------------------------------*/ /* End of compilers - finish up */ #ifndef NO_STDIO_H # include <stdio.h> #endif /* 64 bit ints are usually spelt __int64 unless compiler has overridden */ #define HAVE_LONG_LONG 1 #ifndef PY_LONG_LONG # define PY_LONG_LONG __int64 # define PY_LLONG_MAX _I64_MAX # define PY_LLONG_MIN _I64_MIN # define PY_ULLONG_MAX _UI64_MAX #endif /* 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 */ #if !defined(MS_NO_COREDLL) && !defined(Py_NO_ENABLE_SHARED) # define Py_ENABLE_SHARED 1 /* standard symbol for shared library */ # define MS_COREDLL /* deprecated old symbol */ #endif /* !MS_NO_COREDLL && ... */ /* All windows compilers that use this header support __declspec */ #define HAVE_DECLSPEC_DLL /* For an MSVC DLL, we can nominate the .lib files used by extensions */ #ifdef MS_COREDLL # ifndef Py_BUILD_CORE /* not building the core - must be an ext */ # if defined(_MSC_VER) /* So MSVC users need not specify the .lib file in their Makefile (other compilers are generally taken care of by distutils.) */ # ifdef _DEBUG # pragma comment(lib,"python27_d.lib") # else # pragma comment(lib,"python27.lib") # endif /* _DEBUG */ # endif /* _MSC_VER */ # endif /* Py_BUILD_CORE */ #endif /* MS_COREDLL */ #if defined(MS_WIN64) /* maintain "win32" sys.platform for backward compatibility of Python code, the Win64 API should be close enough to the Win32 API to make this preferable */ # define PLATFORM "win32" # define SIZEOF_VOID_P 8 # define SIZEOF_TIME_T 8 # define SIZEOF_OFF_T 4 # define SIZEOF_FPOS_T 8 # define SIZEOF_HKEY 8 # define SIZEOF_SIZE_T 8 /* configure.ac defines HAVE_LARGEFILE_SUPPORT iff HAVE_LONG_LONG, sizeof(off_t) > sizeof(long), and sizeof(PY_LONG_LONG) >= sizeof(off_t). On Win64 the second condition is not true, but if fpos_t replaces off_t then this is true. The uses of HAVE_LARGEFILE_SUPPORT imply that Win64 should define this. */ # define HAVE_LARGEFILE_SUPPORT #elif defined(MS_WIN32) # define PLATFORM "win32" # define HAVE_LARGEFILE_SUPPORT # define SIZEOF_VOID_P 4 # define SIZEOF_OFF_T 4 # define SIZEOF_FPOS_T 8 # define SIZEOF_HKEY 4 # define SIZEOF_SIZE_T 4 /* MS VS2005 changes time_t to an 64-bit type on all platforms */ # if defined(_MSC_VER) && _MSC_VER >= 1400 # define SIZEOF_TIME_T 8 # else # define SIZEOF_TIME_T 4 # endif #endif #ifdef _DEBUG # define Py_DEBUG #endif #ifdef MS_WIN32 #define SIZEOF_SHORT 2 #define SIZEOF_INT 4 #define SIZEOF_LONG 4 #define SIZEOF_LONG_LONG 8 #define SIZEOF_DOUBLE 8 #define SIZEOF_FLOAT 4 /* VC 7.1 has them and VC 6.0 does not. VC 6.0 has a version number of 1200. Microsoft eMbedded Visual C++ 4.0 has a version number of 1201 and doesn't define these. If some compiler does not provide them, modify the #if appropriately. */ #if defined(_MSC_VER) #if _MSC_VER > 1300 #define HAVE_UINTPTR_T 1 #define HAVE_INTPTR_T 1 #else /* VC6, VS 2002 and eVC4 don't support the C99 LL suffix for 64-bit integer literals */ #define Py_LL(x) x##I64 #endif /* _MSC_VER > 1200 */ #endif /* _MSC_VER */ #endif /* define signed and unsigned exact-width 32-bit and 64-bit types, used in the implementation of Python long integers. */ #ifndef PY_UINT32_T #if SIZEOF_INT == 4 #define HAVE_UINT32_T 1 #define PY_UINT32_T unsigned int #elif SIZEOF_LONG == 4 #define HAVE_UINT32_T 1 #define PY_UINT32_T unsigned long #endif #endif #ifndef PY_UINT64_T #if SIZEOF_LONG_LONG == 8 #define HAVE_UINT64_T 1 #define PY_UINT64_T unsigned PY_LONG_LONG #endif #endif #ifndef PY_INT32_T #if SIZEOF_INT == 4 #define HAVE_INT32_T 1 #define PY_INT32_T int #elif SIZEOF_LONG == 4 #define HAVE_INT32_T 1 #define PY_INT32_T long #endif #endif #ifndef PY_INT64_T #if SIZEOF_LONG_LONG == 8 #define HAVE_INT64_T 1 #define PY_INT64_T PY_LONG_LONG #endif #endif /* Fairly standard from here! */ /* Define to 1 if you have the `copysign' function. */ #define HAVE_COPYSIGN 1 /* Define to 1 if you have the `round' function. */ #if _MSC_VER >= 1800 #define HAVE_ROUND 1 #endif /* Define to 1 if you have the `isinf' macro. */ #define HAVE_DECL_ISINF 1 /* Define to 1 if you have the `isnan' function. */ #define HAVE_DECL_ISNAN 1 /* Define if on AIX 3. System headers sometimes define this. We just want to avoid a redefinition error message. */ #ifndef _ALL_SOURCE /* #undef _ALL_SOURCE */ #endif /* Define to empty if the keyword does not work. */ /* #define const */ /* Define to 1 if you have the <conio.h> header file. */ #ifndef MS_WINCE #define HAVE_CONIO_H 1 #endif /* Define to 1 if you have the <direct.h> header file. */ #ifndef MS_WINCE #define HAVE_DIRECT_H 1 #endif /* Define if you have dirent.h. */ /* #define DIRENT 1 */ /* Define to the type of elements in the array set by `getgroups'. Usually this is either `int' or `gid_t'. */ /* #undef GETGROUPS_T */ /* Define to `int' if <sys/types.h> doesn't define. */ /* #undef gid_t */ /* Define if your struct tm has tm_zone. */ /* #undef HAVE_TM_ZONE */ /* Define if you don't have tm_zone but do have the external array tzname. */ #define HAVE_TZNAME /* Define to `int' if <sys/types.h> doesn't define. */ /* #undef mode_t */ /* Define if you don't have dirent.h, but have ndir.h. */ /* #undef NDIR */ /* Define to `long' if <sys/types.h> doesn't define. */ /* #undef off_t */ /* Define to `int' if <sys/types.h> doesn't define. */ /* #undef pid_t */ /* Define if the system does not provide POSIX.1 features except with this defined. */ /* #undef _POSIX_1_SOURCE */ /* Define if you need to in order for stat and other things to work. */ /* #undef _POSIX_SOURCE */ /* Define as the return type of signal handlers (int or void). */ #define RETSIGTYPE void /* Define to `unsigned' if <sys/types.h> doesn't define. */ /* #undef size_t */ /* Define if you have the ANSI C header files. */ #define STDC_HEADERS 1 /* Define if you don't have dirent.h, but have sys/dir.h. */ /* #undef SYSDIR */ /* Define if you don't have dirent.h, but have sys/ndir.h. */ /* #undef SYSNDIR */ /* Define if you can safely include both <sys/time.h> and <time.h>. */ /* #undef TIME_WITH_SYS_TIME */ /* Define if your <sys/time.h> declares struct tm. */ /* #define TM_IN_SYS_TIME 1 */ /* Define to `int' if <sys/types.h> doesn't define. */ /* #undef uid_t */ /* Define if the closedir function returns void instead of int. */ /* #undef VOID_CLOSEDIR */ /* Define if getpgrp() must be called as getpgrp(0) and (consequently) setpgrp() as setpgrp(0, 0). */ /* #undef GETPGRP_HAVE_ARGS */ /* Define this if your time.h defines altzone */ /* #define HAVE_ALTZONE */ /* Define if you have the putenv function. */ #ifndef MS_WINCE #define HAVE_PUTENV #endif /* Define if your compiler supports function prototypes */ #define HAVE_PROTOTYPES /* Define if you can safely include both <sys/select.h> and <sys/time.h> (which you can't on SCO ODT 3.0). */ /* #undef SYS_SELECT_WITH_SYS_TIME */ /* Define if you want documentation strings in extension modules */ #define WITH_DOC_STRINGS 1 /* Define if you want to compile in rudimentary thread support */ /* #undef WITH_THREAD */ /* Define if you want to use the GNU readline library */ /* #define WITH_READLINE 1 */ /* Define if you want to have a Unicode type. */ #define Py_USING_UNICODE /* Define as the size of the unicode type. */ /* This is enough for unicodeobject.h to do the "right thing" on Windows. */ #define Py_UNICODE_SIZE 2 /* Use Python's own small-block memory-allocator. */ #define WITH_PYMALLOC 1 /* Define if you have clock. */ /* #define HAVE_CLOCK */ /* Define when any dynamic module loading is enabled */ #define HAVE_DYNAMIC_LOADING /* Define if you have ftime. */ #ifndef MS_WINCE #define HAVE_FTIME #endif /* Define if you have getpeername. */ #define HAVE_GETPEERNAME /* Define if you have getpgrp. */ /* #undef HAVE_GETPGRP */ /* Define if you have getpid. */ #ifndef MS_WINCE #define HAVE_GETPID #endif /* Define if you have gettimeofday. */ /* #undef HAVE_GETTIMEOFDAY */ /* Define if you have getwd. */ /* #undef HAVE_GETWD */ /* Define if you have lstat. */ /* #undef HAVE_LSTAT */ /* Define if you have the mktime function. */ #define HAVE_MKTIME /* Define if you have nice. */ /* #undef HAVE_NICE */ /* Define if you have readlink. */ /* #undef HAVE_READLINK */ /* Define if you have select. */ /* #undef HAVE_SELECT */ /* Define if you have setpgid. */ /* #undef HAVE_SETPGID */ /* Define if you have setpgrp. */ /* #undef HAVE_SETPGRP */ /* Define if you have setsid. */ /* #undef HAVE_SETSID */ /* Define if you have setvbuf. */ #define HAVE_SETVBUF /* Define if you have siginterrupt. */ /* #undef HAVE_SIGINTERRUPT */ /* Define if you have symlink. */ /* #undef HAVE_SYMLINK */ /* Define if you have tcgetpgrp. */ /* #undef HAVE_TCGETPGRP */ /* Define if you have tcsetpgrp. */ /* #undef HAVE_TCSETPGRP */ /* Define if you have times. */ /* #undef HAVE_TIMES */ /* Define if you have uname. */ /* #undef HAVE_UNAME */ /* Define if you have waitpid. */ /* #undef HAVE_WAITPID */ /* Define to 1 if you have the `wcscoll' function. */ #ifndef MS_WINCE #define HAVE_WCSCOLL 1 #endif /* Define if the zlib library has inflateCopy */ #define HAVE_ZLIB_COPY 1 /* Define if you have the <dlfcn.h> header file. */ /* #undef HAVE_DLFCN_H */ /* Define to 1 if you have the <errno.h> header file. */ #ifndef MS_WINCE #define HAVE_ERRNO_H 1 #endif /* Define if you have the <fcntl.h> header file. */ #ifndef MS_WINCE #define HAVE_FCNTL_H 1 #endif /* Define to 1 if you have the <process.h> header file. */ #ifndef MS_WINCE #define HAVE_PROCESS_H 1 #endif /* Define to 1 if you have the <signal.h> header file. */ #ifndef MS_WINCE #define HAVE_SIGNAL_H 1 #endif /* Define if you have the <stdarg.h> prototypes. */ #define HAVE_STDARG_PROTOTYPES /* Define if you have the <stddef.h> header file. */ #define HAVE_STDDEF_H 1 /* Define if you have the <sys/audioio.h> header file. */ /* #undef HAVE_SYS_AUDIOIO_H */ /* Define if you have the <sys/param.h> header file. */ /* #define HAVE_SYS_PARAM_H 1 */ /* Define if you have the <sys/select.h> header file. */ /* #define HAVE_SYS_SELECT_H 1 */ /* Define to 1 if you have the <sys/stat.h> header file. */ #ifndef MS_WINCE #define HAVE_SYS_STAT_H 1 #endif /* Define if you have the <sys/time.h> header file. */ /* #define HAVE_SYS_TIME_H 1 */ /* Define if you have the <sys/times.h> header file. */ /* #define HAVE_SYS_TIMES_H 1 */ /* Define to 1 if you have the <sys/types.h> header file. */ #ifndef MS_WINCE #define HAVE_SYS_TYPES_H 1 #endif /* Define if you have the <sys/un.h> header file. */ /* #define HAVE_SYS_UN_H 1 */ /* Define if you have the <sys/utime.h> header file. */ /* #define HAVE_SYS_UTIME_H 1 */ /* Define if you have the <sys/utsname.h> header file. */ /* #define HAVE_SYS_UTSNAME_H 1 */ /* Define if you have the <thread.h> header file. */ /* #undef HAVE_THREAD_H */ /* Define if you have the <unistd.h> header file. */ /* #define HAVE_UNISTD_H 1 */ /* Define if you have the <utime.h> header file. */ /* #define HAVE_UTIME_H 1 */ /* Define if the compiler provides a wchar.h header file. */ #define HAVE_WCHAR_H 1 /* Define if you have the dl library (-ldl). */ /* #undef HAVE_LIBDL */ /* Define if you have the mpc library (-lmpc). */ /* #undef HAVE_LIBMPC */ /* Define if you have the nsl library (-lnsl). */ #define HAVE_LIBNSL 1 /* Define if you have the seq library (-lseq). */ /* #undef HAVE_LIBSEQ */ /* Define if you have the socket library (-lsocket). */ #define HAVE_LIBSOCKET 1 /* Define if you have the sun library (-lsun). */ /* #undef HAVE_LIBSUN */ /* Define if you have the termcap library (-ltermcap). */ /* #undef HAVE_LIBTERMCAP */ /* Define if you have the termlib library (-ltermlib). */ /* #undef HAVE_LIBTERMLIB */ /* Define if you have the thread library (-lthread). */ /* #undef HAVE_LIBTHREAD */ /* WinSock does not use a bitmask in select, and uses socket handles greater than FD_SETSIZE */ #define Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE /* Define if C doubles are 64-bit IEEE 754 binary format, stored with the least significant byte first */ #define DOUBLE_IS_LITTLE_ENDIAN_IEEE754 1 #endif /* !Py_CONFIG_H */
_______________________________________________ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32