2

I need to use some boost (boost/numeric/ublas/matrix.hpp) in my ObjectiveC/Foundation project. I installed boost using Homebrew (an it works in C++ Xcode project).

I use XCode 4.2.1 (clang 3.0) under Lion 10.7.2. I created and empty Foundation project, added new ObjC class and included #include <boost/numeric/ublas/matrix.hpp>. It game me numerous warnings.

My MAMatrix.mm (.mm means ObjC++):

#import "MAMatrix.h"
#include <boost/numeric/ublas/matrix.hpp>

@implementation MAMatrix

- (id)initWithSize:(NSUInteger)aSize
{    
    return [self initWithHeight:aSize 
                          width:aSize];
}

- (id)initWithHeight:(NSUInteger)anHeight 
               width:(NSUInteger)anWidth
{    
    self = [super init];
    if (self) {
        ;
    }

    return self;
}

@end

I am getting

In file included from MAMatrix.mm:11:
In file included from /usr/local/include/boost/numeric/ublas/matrix.hpp:16:
In file included from /usr/local/include/boost/numeric/ublas/vector.hpp:19:
In file included from /usr/local/include/boost/numeric/ublas/storage.hpp:26:
In file included from /usr/local/include/boost/numeric/ublas/traits.hpp:24:
In file included from /usr/local/include/boost/type_traits.hpp:35:
In file included from /usr/local/include/boost/type_traits/has_operator.hpp:12:
In file included from /usr/local/include/boost/type_traits/has_bit_and.hpp:43:
/usr/local/include/boost/type_traits/detail/has_binary_operator.hpp:157:4: error: expected expression
   BOOST_STATIC_CONSTANT(bool, value = (sizeof(check(((make<Lhs>() BOOST_TT_TRAIT_OP ...
   ^
/usr/local/include/boost/config/suffix.hpp:431:72: note: instantiated from:
#     define BOOST_STATIC_CONSTANT(type, assignment) static const type assignment
                                                                       ^
/usr/local/include/boost/type_traits/detail/has_binary_operator.hpp:157:121: note: instantiated from:
   BOOST_STATIC_CONSTANT(bool, value = (sizeof(check(((make<Lhs>() BOOST_TT_TRAIT_OP make<Rhs>()),make<has_operator>())))=...
                                                                                                                        ^

In

template < typename Lhs, typename Rhs >
struct operator_exists {
   static ::boost::type_traits::yes_type check(has_operator); // this version is preferred when operator exists
   static ::boost::type_traits::no_type check(no_operator); // this version is used otherwise

   BOOST_STATIC_CONSTANT(bool, value = (sizeof(check(((make<Lhs>() BOOST_TT_TRAIT_OP make<Rhs>()),make<has_operator>())))==sizeof(::boost::type_traits::yes_type)));
};

I think it may be a boost issue, because STL works fine in my ObjC class.

Thanks for help.

kubbing
  • 7,219
  • 4
  • 23
  • 18

1 Answers1

0

Solved using this c-boost-1-48-type-traits-and-cocoa-inclusion-weirdness

I included the #include <boost/numeric/ublas/matrix.hpp> in the header file BEFORE Founfation.h

Weird hack for latest 1.48.0 Boost…

Community
  • 1
  • 1
kubbing
  • 7,219
  • 4
  • 23
  • 18
  • 1
    I couldn't do you weird hack. Too many source files, too complex header file dependency to make something like that work. I was upgrading from boos 1.35.0 to boost 1.48.0. For now I've resolved the issue for us by upgrading to 1.47.0 only for now. –  Dec 09 '11 at 16:22
  • Same problem here, couldn't use your hack, but will downgrade to 1.47 too if possible. – scippie Jun 01 '12 at 14:13
  • Just tried 1.49.0, it doesn't work either. Does someone know how to contact boost-people and notify them about this problem? – scippie Jun 01 '12 at 14:43