2011-12-03 25 views
2

我需要在我的ObjectiveC/Foundation項目中使用一些boost(boost/numeric/ublas/matrix.hpp)。我使用Homebrew安裝了boost(它在C++ Xcode項目中有效)。目標C類中的Boost矩陣不能編譯

我在Lion 10.7.2下使用XCode 4.2.1(clang 3.0)。我創建並清空了Foundation項目,添加了新的ObjC類幷包含#include <boost/numeric/ublas/matrix.hpp>。它與我遊戲無數的警告。

我MAMatrix.mm(.mm意味着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 

我越來越

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>())))=... 
                                 ^

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))); 
}; 

我認爲這可能是一個提升的問題,因爲STL在我的ObjC類中工作正常。

感謝您的幫助。

回答

0

使用該c-boost-1-48-type-traits-and-cocoa-inclusion-weirdness

解決我包含在頭文件中#include <boost/numeric/ublas/matrix.hpp> BEFORE Founfation.h

奇怪的黑客對最新的1.48.0升壓...

+1

我不能做你怪異的黑客。太多的源文件,太複雜的頭文件依賴性,使這樣的工作。我從噓1.35.0升級到1.48.0。目前爲止,我現在只通過升級到1.47.0來解決這個問題。 – 2011-12-09 16:22:26

+0

同樣的問題在這裏,不能使用你的黑客,但如果可能的話,也會降級到1.47。 – scippie

+0

剛剛試過1.49.0,它也不起作用。有人知道如何聯繫助推員並告知他們這個問題嗎? – scippie