Opened 9 years ago

Closed 8 years ago

Last modified 8 years ago

#50100 closed defect (fixed)

clang-3.8 fails to support Boost.Python

Reported by: akimd (Akim Demaille) Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: ports Version: 2.3.4
Keywords: C++ Cc: jeremyhu (Jeremy Huddleston Sequoia), larryv (Lawrence Velázquez), ryandesign (Ryan Carsten Schmidt), michaelld (Michael Dickens), Ionic (Mihai Moldovan)
Port: clang-3.8 boost python34

Description

Hi,

I'm unsure where I should report this bug: it happens with Boost.Python (1.59) and Clang 3.8. It does not happen with Clang 3.7 and previous, so that's why I send it here.

The following program fails to compile:

$ cat foo.cc
#include <boost/python.hpp>

int main() {}
$ clang++-mp-3.8 -I /opt/local/include/ -I/opt/local/Library/Frameworks/Python.framework/Versions/3.4/include/python3.4m foo.cc |& head -50
In file included from foo.cc:1:
In file included from /opt/local/include/boost/python.hpp:11:
In file included from /opt/local/include/boost/python/args.hpp:25:
In file included from /opt/local/include/boost/python/object_core.hpp:14:
In file included from /opt/local/include/boost/python/call.hpp:15:
In file included from /opt/local/include/boost/python/converter/arg_to_python.hpp:10:
In file included from /opt/local/include/boost/python/to_python_indirect.hpp:10:
In file included from /opt/local/include/boost/python/object/pointer_holder.hpp:14:
In file included from /opt/local/include/boost/python/instance_holder.hpp:11:
In file included from /opt/local/include/boost/python/type_id.hpp:14:
In file included from /opt/local/libexec/llvm-3.8/bin/../include/c++/v1/ostream:138:
In file included from /opt/local/libexec/llvm-3.8/bin/../include/c++/v1/ios:216:
/opt/local/libexec/llvm-3.8/bin/../include/c++/v1/__locale:468:15: error: C++ requires a type specifier for all declarations
    char_type toupper(char_type __c) const
              ^
/opt/local/Library/Frameworks/Python.framework/Versions/3.4/include/python3.4m/pyport.h:709:29: note: expanded from macro 'toupper'
#define toupper(c) towupper(btowc(c))
                            ^
In file included from foo.cc:1:
In file included from /opt/local/include/boost/python.hpp:11:
In file included from /opt/local/include/boost/python/args.hpp:25:
In file included from /opt/local/include/boost/python/object_core.hpp:14:
In file included from /opt/local/include/boost/python/call.hpp:15:
In file included from /opt/local/include/boost/python/converter/arg_to_python.hpp:10:
In file included from /opt/local/include/boost/python/to_python_indirect.hpp:10:
In file included from /opt/local/include/boost/python/object/pointer_holder.hpp:14:
In file included from /opt/local/include/boost/python/instance_holder.hpp:11:
In file included from /opt/local/include/boost/python/type_id.hpp:14:
In file included from /opt/local/libexec/llvm-3.8/bin/../include/c++/v1/ostream:138:
In file included from /opt/local/libexec/llvm-3.8/bin/../include/c++/v1/ios:216:
/opt/local/libexec/llvm-3.8/bin/../include/c++/v1/__locale:474:48: error: too many arguments provided to function-like macro invocation
    const char_type* toupper(char_type* __low, const char_type* __high) const
                                               ^
/opt/local/Library/Frameworks/Python.framework/Versions/3.4/include/python3.4m/pyport.h:709:9: note: macro 'toupper' defined here
#define toupper(c) towupper(btowc(c))
        ^
In file included from foo.cc:1:
In file included from /opt/local/include/boost/python.hpp:11:
In file included from /opt/local/include/boost/python/args.hpp:25:
In file included from /opt/local/include/boost/python/object_core.hpp:14:
In file included from /opt/local/include/boost/python/call.hpp:15:
In file included from /opt/local/include/boost/python/converter/arg_to_python.hpp:10:
In file included from /opt/local/include/boost/python/to_python_indirect.hpp:10:
In file included from /opt/local/include/boost/python/object/pointer_holder.hpp:14:
In file included from /opt/local/include/boost/python/instance_holder.hpp:11:
In file included from /opt/local/include/boost/python/type_id.hpp:14:
In file included from /opt/local/libexec/llvm-3.8/bin/../include/c++/v1/ostream:138:
In file included from /opt/local/libexec/llvm-3.8/bin/../include/c++/v1/ios:216:
/opt/local/libexec/llvm-3.8/bin/../include/c++/v1/__locale:474:29: error: expected ';' at end of declaration list
    const char_type* toupper(char_type* __low, const char_type* __high) const
$

It is related to these bits in /opt/local/Library/Frameworks/Python.framework/Versions/3.4/include/python3.4m/pyport.h:

#if defined(__APPLE__)
# define _PY_PORT_CTYPE_UTF8_ISSUE
#endif

#ifdef _PY_PORT_CTYPE_UTF8_ISSUE
#include <ctype.h>
#include <wctype.h>
#undef isalnum
#define isalnum(c) iswalnum(btowc(c))
#undef isalpha
#define isalpha(c) iswalpha(btowc(c))
#undef islower
#define islower(c) iswlower(btowc(c))
#undef isspace
#define isspace(c) iswspace(btowc(c))
#undef isupper
#define isupper(c) iswupper(btowc(c))
#undef tolower
#define tolower(c) towlower(btowc(c))
#undef toupper
#define toupper(c) towupper(btowc(c))
#endif

My guess is that Python was ready to see these functions being defined _before_ pyport.h being included, but not after, as is now the case. And indeed, if I include <locale> before Boost.Python, it works. So it might be Boost.Python that might need a fix.

Change History (4)

comment:1 Changed 9 years ago by akimd (Akim Demaille)

I just found this ticket: #44288, which is related. So it appears that the problem is rather to be solved in python-3.4.

Last edited 9 years ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

comment:2 Changed 9 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Yes, it is a bug in the python's headers.

comment:3 Changed 8 years ago by Ionic (Mihai Moldovan)

Cc: Ionic added
Resolution: fixed
Status: newclosed

Should be fixed since all affected python ports have been modified with a backported patch as part of #51939.

Last edited 8 years ago by Ionic (Mihai Moldovan) (previous) (diff)

comment:4 Changed 8 years ago by akimd (Akim Demaille)

you are right, it works. Thanks!

Note: See TracTickets for help on using tickets.