Problem building Win32 extensions

Jonathan Gilligan jonathan.gilligan at vanderbilt.edu
Tue Oct 17 19:05:39 EDT 2000


I have a major problem trying to build Mark Hammond's Win32
extensions. Here is the short description: Mark's wrappers are .cpp
files, but wrap the inclusion of python.h with an

extern "C" {
#include "Python.h"
}

Python.h in turn includes standard c headers such as <math.h>. Here is
the problem. Under VC++ 6.0 SP4, math.h has the following lines:

#ifdef  __cplusplus
...
template<class _Ty> inline
        _Ty _Pow_int(_Ty _X, int _Y)
        {unsigned int _N;
        if (_Y >= 0)
                _N = _Y;
        else
                _N = -_Y;
        for (_Ty _Z = _Ty(1); ; _X *= _X)
                {if ((_N & 1) != 0)
                        _Z *= _X;
                if ((_N >>= 1) == 0)
                        return (_Y < 0 ? _Ty(1) / _Z : _Z); }}
...
// JMG note: the following is an overloaded file. Note that
wmemchr(wchar)t *, wchar_t, size_t) calls
// wmemchr(const wchar_t*, wchar_t, size_t).

inline wchar_t *wmemchr(wchar_t *_S, wchar_t _C, size_t _N)
        {return ((wchar_t *)wmemchr((const wchar_t *)_S, _C, _N)); }

The problem is that when I try to compile the win32 extensions, I get
a pile of error messages like this:

--------------------Configuration: win32event - Win32
Release--------------------
Compiling...
win32eventmodule.cpp
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\math.h(514) :
error C2894: templates cannot be declared to have 'C' linkage
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\wchar.h(700) :
error C2733: second C linkage of overloaded function 'wmemchr' not
allowed
        D:\Program Files\Microsoft Visual
Studio\VC98\INCLUDE\wchar.h(699) : see declaration of 'wmemchr'

Can Mark or someone else help me to figure out how to address this
problem?

Here are the grubby details:

I am building everything from scratch thus:
On a clean system, Check out python -r release20 to with cvs. Build
it. Edit the registry manually to make the file associations for .py,
.pyc, .pyw, HKCR. Add HKLM\Software\Python\PythonCore\2.0\PythonPath
with the appropriate Python Path. Python seems to work fine.

Now to Win32 extensions. Check out PyWin32 to PyWin32Ex. Download and
install Mark Hammond special SWIG 1.1. Set SWIG_EXE and SWIG_LIB
environment variables appropriately. Open VC++ and load "Python and
Extensions.dsw". Set Tools/Options to add Python directories to the
Include and Lib sections.

I can build "_All Pythonwin" with no errors, although a few warnings.
However, when I try to build "_win32 projects" I am dead in the water
with the error messages listed above.

Can Mark or anyone else help me with this?

Thanks in advance,
Jonathan Gilligan





More information about the Python-list mailing list