Python.h bug?

Stephen Langer stephen.langer at nist.gov
Fri May 20 06:57:46 PDT 2011


Hi --

Can someone tell me if I'm crazy before I submit a bug report on this?  The following short program fails to compile when using Python.h from MacPorts python version 2.6 or 2.7.  It compiles with python 2.5, and it compiles on all varieties of Linux with all versions of python that I've tried.  It also compiles with the Apple system python.

Here's the program:

--------
#include <algorithm>
#include <Python.h>
#include <iostream>

int main(int, char**) {
  std::cout << "Hello, world!" << std::endl;
}
--------

Compile with 
  g++ -I /opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 test.C
or
  g++ -I /opt/local/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 test.C
to see it fail, or
  g++ -I /opt/local/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 test.C
or
  g++ -I /usr/include/python2.6 test.C
to see it succeed.

If the order of the #includes is changed in any way, the program compiles successfully even with python 2.6 or 2.7.  Changing "<algorithm>" to "<vector>" or other STL headers doesn't seem to have any effect.

I'm using OS X 10.6.7 and my MacPorts is up to date.

Thanks.

 -- Steve


--
-- stephen.langer at nist.gov                    Tel: (301) 975-5423 --
-- http://math.nist.gov/~SLanger/             Fax: (301) 975-3553 --
-- NIST, 100 Bureau Drive, Stop 8910, Gaithersburg, Md 20899-8910 --

-- "I don't think this will work.  That's why it's science."      --
--                     Naomi Langer (age 6),  17 Feb 2003         --








More information about the macports-users mailing list