Programming Python - examples from the book work, no?

Gordon McMillan gmcm at hypernet.com
Mon Jun 7 09:22:49 EDT 1999


Thomas S. Strinnhed writes:
> 
> Doing everything in MSVC++ on NT I try to run the Example 14-2
> (p534-540 ) from "Programming Python" by Mark Lutz. I run it just
> like it comes on the CD included with the book
> (CD-DRIVE:/Examples/DOS/Extend/Stacktyp.c) trying to extend Python
> with this Stack-type. BUT: I get an I-don't-know-what-this-is-about
> kind of compiler error, complaing about this call:
> PyObject_HEAD_INIT(&PyType_Type)  with message "initializer is not a
> constant".

While every other C compiler on earth allows this, MS decided on a 
very literal reading of the C language spec. The easiest way around 
it is to change the extension on your file to .cpp. The "proper" way 
around it is to define the type object with a NULL in this slot, and 
then assign &PyType_Type to it after it has been created.

sand-in-the-vaseline-goes-with-embrace-and-extend-ly y'rs

- Gordon




More information about the Python-list mailing list