I recently tried to compile Inline::Python 0.22 on Win32 with Visual C++ 7.1. I started with the usual build mantra.
perl Makefile.PL nmake nmake test nmake install
But I only got up to "nmake," and got hit by the following compiler error.
perlmodule.c(160) : error C2099: initializer is not a constant
By the way, it's the very same thing with Visual C++ 8.0, also known as Visual C++ 2005.
The problem comes from the following code snippet.
DL_EXPORT(PyTypeObject) PerlPkg_type = {
PyObject_HEAD_INIT(&PyType_Type)
0, /*ob_size*/
...
};
The offending part is "PyObject_HEAD_INIT(&PyType_Type)
" because it is not strictly conforming C, as explained in the Python documentation. The solution is also explained there: Replace the construct with the following one.
PyObject_HEAD_INIT(NULL)
There are two more places with the same construct, which I had to replace too. Another "nmake," and the module was compiled. The test were passing too.
>nmake test All tests successful, 58 subtests skipped.