[C++-sig] compile-time macro errors when using Python 2.7.1 and Boost 1.45 on OSX 10.6.6

Athanasios Dousis athanasios.dousis at protabit.com
Thu Mar 10 00:49:49 CET 2011


I've appended this issue to the Python bug tracker http://bugs.python.org/issue10910

On Mar 2, 2011, at 11:17 AM, Athanasios Dousis wrote:

> Hello all,
> 
> I'm upgrading from Python 2.6.5 to 2.7.1, and I'm getting the error below when compiling my program using Boost 1.45 and gcc 4.2.1 in OSX 10.6.6.  I found a thread that describes similar symptoms related to the ordering of header files and macro definitions:
> http://code.google.com/p/unladen-swallow/issues/detail?id=87#c13
> 
> The suggested patch to pyport.h (http://codereview.appspot.com/179049/patch/1/2) does not fix my problem, presumably because I'm not using FreeBSD.  However, adding #include "Python.h" to the top of each source file (e.g., bend.cc below) does fix the problem.  Is there a simple way to fix this without adding Python.h to every source file in my codebase?
> 
> I've installed Boost and Python from source to non-standard directories, Boost 1.45 by:
> cd $(BOOST); ./bootstrap.sh --prefix=$(CURDIR)/$(BOOST) --with-python-root=$(CURDIR)/$(PYTHON_DIR) --with-python-version=2.7 --with-libraries=mpi
> 
> and Python 2.7 by:
> cd $(PYTHON_SRCDIR) ; ./configure --enable-shared --prefix=$(CURDIR)/$(PYTHON_DIR)
> cd $(PYTHON_SRCDIR) ; make -j $(NUMPROC) && make install
> 
> Any guidance will be greatly appreciated.
> 
> Kind regards,
> Nasos
> 
> ===============
> ...
> darwin.compile.c++ bin/darwin-4.2.1/release/threading-multi/bend.o
> In file included from /usr/include/c++/4.2.1/ios:47,
>                  from /usr/include/c++/4.2.1/ostream:45,
>                  from /usr/include/c++/4.2.1/iterator:70,
>                  from boost/boost/next_prior.hpp:15,
>                  from boost/boost/utility.hpp:17,
>                  from boost/boost/python/instance_holder.hpp:10,
>                  from boost/boost/python/object/pointer_holder.hpp:14,
>                  from boost/boost/python/to_python_indirect.hpp:10,
>                  from boost/boost/python/converter/arg_to_python.hpp:10,
>                  from boost/boost/python/call.hpp:15,
>                  from boost/boost/python/object_core.hpp:14,
>                  from boost/boost/python/args.hpp:25,
>                  from boost/boost/python.hpp:11,
>                  from bend.hh:6,
>                  from bend.cc:1:
> /usr/include/c++/4.2.1/bits/localefwd.h:58:34: error: macro "isspace" passed 2 arguments, but takes just 1
> /usr/include/c++/4.2.1/bits/localefwd.h:70:34: error: macro "isupper" passed 2 arguments, but takes just 1
> /usr/include/c++/4.2.1/bits/localefwd.h:74:34: error: macro "islower" passed 2 arguments, but takes just 1
> /usr/include/c++/4.2.1/bits/localefwd.h:78:34: error: macro "isalpha" passed 2 arguments, but takes just 1
> /usr/include/c++/4.2.1/bits/localefwd.h:94:34: error: macro "isalnum" passed 2 arguments, but takes just 1
> /usr/include/c++/4.2.1/bits/localefwd.h:102:34: error: macro "toupper" passed 2 arguments, but takes just 1
> /usr/include/c++/4.2.1/bits/localefwd.h:106:34: error: macro "tolower" passed 2 arguments, but takes just 1
> In file included from /usr/include/c++/4.2.1/bits/basic_ios.h:44,
>                  from /usr/include/c++/4.2.1/ios:50,
>                  from /usr/include/c++/4.2.1/ostream:45,
>                  from /usr/include/c++/4.2.1/iterator:70,
>                  from boost/boost/next_prior.hpp:15,
>                  from boost/boost/utility.hpp:17,
>                  from boost/boost/python/instance_holder.hpp:10,
>                  from boost/boost/python/object/pointer_holder.hpp:14,
>                  from boost/boost/python/to_python_indirect.hpp:10,
>                  from boost/boost/python/converter/arg_to_python.hpp:10,
>                  from boost/boost/python/call.hpp:15,
>                  from boost/boost/python/object_core.hpp:14,
>                  from boost/boost/python/args.hpp:25,
>                  from boost/boost/python.hpp:11,
>                  from bend.hh:6,
>                  from bend.cc:1:
> /usr/include/c++/4.2.1/bits/locale_facets.h:242:53: error: macro "toupper" passed 2 arguments, but takes just 1
> /usr/include/c++/4.2.1/bits/locale_facets.h:271:53: error: macro "tolower" passed 2 arguments, but takes just 1
> /usr/include/c++/4.2.1/bits/locale_facets.h:814:53: error: macro "toupper" passed 2 arguments, but takes just 1
> /usr/include/c++/4.2.1/bits/locale_facets.h:847:53: error: macro "tolower" passed 2 arguments, but takes just 1
> /usr/include/c++/4.2.1/bits/locale_facets.h:4611:44: error: macro "isspace" passed 2 arguments, but takes just 1
> /usr/include/c++/4.2.1/bits/locale_facets.h:4629:44: error: macro "isupper" passed 2 arguments, but takes just 1
> /usr/include/c++/4.2.1/bits/locale_facets.h:4635:44: error: macro "islower" passed 2 arguments, but takes just 1
> /usr/include/c++/4.2.1/bits/locale_facets.h:4641:44: error: macro "isalpha" passed 2 arguments, but takes just 1
> /usr/include/c++/4.2.1/bits/locale_facets.h:4665:44: error: macro "isalnum" passed 2 arguments, but takes just 1
> /usr/include/c++/4.2.1/bits/locale_facets.h:4677:44: error: macro "toupper" passed 2 arguments, but takes just 1
> /usr/include/c++/4.2.1/bits/locale_facets.h:4683:44: error: macro "tolower" passed 2 arguments, but takes just 1
> In file included from /usr/include/c++/4.2.1/ios:47,
>                  from /usr/include/c++/4.2.1/ostream:45,
>                  from /usr/include/c++/4.2.1/iterator:70,
>                  from boost/boost/next_prior.hpp:15,
>                  from boost/boost/utility.hpp:17,
>                  from boost/boost/python/instance_holder.hpp:10,
>                  from boost/boost/python/object/pointer_holder.hpp:14,
>                  from boost/boost/python/to_python_indirect.hpp:10,
>                  from boost/boost/python/converter/arg_to_python.hpp:10,
>                  from boost/boost/python/call.hpp:15,
>                  from boost/boost/python/object_core.hpp:14,
>                  from boost/boost/python/args.hpp:25,
>                  from boost/boost/python.hpp:11,
>                  from bend.hh:6,
>                  from bend.cc:1:
> /usr/include/c++/4.2.1/bits/localefwd.h:58: error: ‘std::isspace’ declared as an ‘inline’ variable
> /usr/include/c++/4.2.1/bits/localefwd.h:58: error: template declaration of ‘bool std::isspace’
> /usr/include/c++/4.2.1/bits/localefwd.h:70: error: ‘std::isupper’ declared as an ‘inline’ variable
> /usr/include/c++/4.2.1/bits/localefwd.h:70: error: template declaration of ‘bool std::isupper’
> /usr/include/c++/4.2.1/bits/localefwd.h:74: error: ‘std::islower’ declared as an ‘inline’ variable
> /usr/include/c++/4.2.1/bits/localefwd.h:74: error: template declaration of ‘bool std::islower’
> /usr/include/c++/4.2.1/bits/localefwd.h:78: error: ‘std::isalpha’ declared as an ‘inline’ variable
> /usr/include/c++/4.2.1/bits/localefwd.h:78: error: template declaration of ‘bool std::isalpha’
> /usr/include/c++/4.2.1/bits/localefwd.h:94: error: ‘std::isalnum’ declared as an ‘inline’ variable
> /usr/include/c++/4.2.1/bits/localefwd.h:94: error: template declaration of ‘bool std::isalnum’
> /usr/include/c++/4.2.1/bits/localefwd.h:102: error: ‘std::toupper’ declared as an ‘inline’ variable
> /usr/include/c++/4.2.1/bits/localefwd.h:102: error: template declaration of ‘_CharT std::toupper’
> /usr/include/c++/4.2.1/bits/localefwd.h:106: error: ‘std::tolower’ declared as an ‘inline’ variable
> /usr/include/c++/4.2.1/bits/localefwd.h:106: error: template declaration of ‘_CharT std::tolower’
> In file included from /usr/include/c++/4.2.1/bits/basic_ios.h:44,
>                  from /usr/include/c++/4.2.1/ios:50,
>                  from /usr/include/c++/4.2.1/ostream:45,
>                  from /usr/include/c++/4.2.1/iterator:70,
>                  from boost/boost/next_prior.hpp:15,
>                  from boost/boost/utility.hpp:17,
>                  from boost/boost/python/instance_holder.hpp:10,
>                  from boost/boost/python/object/pointer_holder.hpp:14,
>                  from boost/boost/python/to_python_indirect.hpp:10,
>                  from boost/boost/python/converter/arg_to_python.hpp:10,
>                  from boost/boost/python/call.hpp:15,
>                  from boost/boost/python/object_core.hpp:14,
>                  from boost/boost/python/args.hpp:25,
>                  from boost/boost/python.hpp:11,
>                  from bend.hh:6,
>                  from bend.cc:1:
> /usr/include/c++/4.2.1/bits/locale_facets.h:227: error: ‘btowc’ is not a type
> /usr/include/c++/4.2.1/bits/locale_facets.h:242: error: expected ‘;’ before ‘const’
> /usr/include/c++/4.2.1/bits/locale_facets.h:255: error: expected `;' before ‘char_type’
> /usr/include/c++/4.2.1/bits/locale_facets.h:256: error: ‘btowc’ is not a type
> /usr/include/c++/4.2.1/bits/locale_facets.h:271: error: expected ‘;’ before ‘const’
> /usr/include/c++/4.2.1/bits/locale_facets.h:287: error: expected `;' before ‘char_type’
> /usr/include/c++/4.2.1/bits/locale_facets.h: In member function ‘_CharT std::__ctype_abstract_base<_CharT>::towupper(int (*)(_CharT)) const’:
> /usr/include/c++/4.2.1/bits/locale_facets.h:228: error: ‘__c’ was not declared in this scope
> /usr/include/c++/4.2.1/bits/locale_facets.h: In member function ‘_CharT std::__ctype_abstract_base<_CharT>::towlower(int (*)(_CharT)) const’:
> /usr/include/c++/4.2.1/bits/locale_facets.h:257: error: ‘__c’ was not declared in this scope
> /usr/include/c++/4.2.1/bits/locale_facets.h: At global scope:
> /usr/include/c++/4.2.1/bits/locale_facets.h:797: error: ‘btowc’ is not a type
> /usr/include/c++/4.2.1/bits/locale_facets.h:814: error: expected ‘;’ before ‘const’
> /usr/include/c++/4.2.1/bits/locale_facets.h:829: error: expected `;' before ‘char_type’
> /usr/include/c++/4.2.1/bits/locale_facets.h:830: error: ‘btowc’ is not a type
> /usr/include/c++/4.2.1/bits/locale_facets.h:847: error: expected ‘;’ before ‘const’
> /usr/include/c++/4.2.1/bits/locale_facets.h:866: error: expected `;' before ‘char_type’
> /usr/include/c++/4.2.1/bits/locale_facets.h: In member function ‘char std::ctype<char>::towupper(int (*)(char)) const’:
> /usr/include/c++/4.2.1/bits/locale_facets.h:798: error: ‘__c’ was not declared in this scope
> /usr/include/c++/4.2.1/bits/locale_facets.h: In member function ‘char std::ctype<char>::towlower(int (*)(char)) const’:
> /usr/include/c++/4.2.1/bits/locale_facets.h:831: error: ‘__c’ was not declared in this scope
> In file included from /usr/include/c++/4.2.1/bits/basic_ios.h:44,
>                  from /usr/include/c++/4.2.1/ios:50,
>                  from /usr/include/c++/4.2.1/ostream:45,
>                  from /usr/include/c++/4.2.1/iterator:70,
>                  from boost/boost/next_prior.hpp:15,
>                  from boost/boost/utility.hpp:17,
>                  from boost/boost/python/instance_holder.hpp:10,
>                  from boost/boost/python/object/pointer_holder.hpp:14,
>                  from boost/boost/python/to_python_indirect.hpp:10,
>                  from boost/boost/python/converter/arg_to_python.hpp:10,
>                  from boost/boost/python/call.hpp:15,
>                  from boost/boost/python/object_core.hpp:14,
>                  from boost/boost/python/args.hpp:25,
>                  from boost/boost/python.hpp:11,
>                  from bend.hh:6,
>                  from bend.cc:1:
> /usr/include/c++/4.2.1/bits/locale_facets.h: At global scope:
> /usr/include/c++/4.2.1/bits/locale_facets.h:4611: error: function definition does not declare parameters
> /usr/include/c++/4.2.1/bits/locale_facets.h:4629: error: function definition does not declare parameters
> /usr/include/c++/4.2.1/bits/locale_facets.h:4635: error: function definition does not declare parameters
> /usr/include/c++/4.2.1/bits/locale_facets.h:4641: error: function definition does not declare parameters
> /usr/include/c++/4.2.1/bits/locale_facets.h:4665: error: function definition does not declare parameters
> /usr/include/c++/4.2.1/bits/locale_facets.h:4677: error: function definition does not declare parameters
> /usr/include/c++/4.2.1/bits/locale_facets.h:4683: error: function definition does not declare parameters
> 
>     "g++"  -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -g -dynamic -no-cpp-precomp -gdwarf-2 -fPIC -Wstrict-aliasing=2 -ffast-math -fno-strict-aliasing -DBOOST_PYTHON_MAX_ARITY=30 -D_REENTRANT  -I"boost" -I"python/include/python2.7" -c -o "bin/darwin-4.2.1/release/threading-multi/Dbend.o" "bend.cc"
> 
> ...failed darwin.compile.c++ bin/darwin-4.2.1/release/threading-multi/bend.o...
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20110309/e420686e/attachment-0001.html>


More information about the Cplusplus-sig mailing list