2014-01-15 40 views
1

试图找出如何从Objective-C++中使用BGL。有什么不对劲。重新制作步骤:如何从Objective-C++使用Boost图库?

  1. 新可可应用程序项目。
  2. 重命名MyAppDelegate.m到MyAppDelegate.mm
  3. 添加#include <boost/shared_ptr.hpp>到MyAppDelegate.mm(工精细,假设你有你的头搜索路径设置正确。)
  4. 添加#include <boost/graph/adjacency_list.hpp>到MyAppDelegate.mm

boost/graph/adjacency_list.hpp传递地包含的某些内容与Cocoa头文件正在传递导入的一些旧的Carbon头相碰撞。下面是输出我看到(的第一个错误的价值无论如何):

In file included from /Users/me/Documents/Projects/BoostTest/BoostTest/MyAppDelegate.mm:10: 
In file included from /Users/me/Documents/Projects/BoostTest/boost/graph/adjacency_list.hpp:33: 
In file included from /Users/me/Documents/Projects/BoostTest/boost/graph/graph_traits.hpp:27: 
In file included from /Users/me/Documents/Projects/BoostTest/boost/pending/property.hpp:13: 
In file included from /Users/me/Documents/Projects/BoostTest/boost/type_traits.hpp:35: 
In file included from /Users/me/Documents/Projects/BoostTest/boost/type_traits/has_operator.hpp:12: 
In file included from /Users/me/Documents/Projects/BoostTest/boost/type_traits/has_bit_and.hpp:43: 
/Users/me/Documents/Projects/BoostTest/boost/type_traits/detail/has_binary_operator.hpp:154:42: error: expected member name or ';' after declaration specifiers 
    static ::boost::type_traits::yes_type check(has_operator); // this version is preferred when operator exists 
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
In file included from /Users/me/Documents/Projects/BoostTest/BoostTest/MyAppDelegate.mm:9: 
In file included from /Users/me/Documents/Projects/BoostTest/BoostTest/MyAppDelegate.h:9: 
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:12: 
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:76: 
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSURLError.h:12: 
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:23: 
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/AE.framework/Headers/AE.h:20: 
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/CarbonCore.h:115: 
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/Debugging.h:212: 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/AssertMacros.h:1291:28: note: expanded from macro 'check' 
     #define check(assertion) __Check(assertion) 
           ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/AssertMacros.h:280:5: note: expanded from macro '__Check' 
        do                  \ 
       ^

如果我包括MyAppDelegate.mm事情将编译<Cocoa/Cocoa.h>之前从该项目的前缀头取出#import <Cocoa/Cocoa.h>,然后#include <boost/graph/adjacency_list.hpp>,但这是分 - 最优/不希望的。

有没有简单的我可以做的(理想情况下在前缀头部,所以我不必这样做到处),使可可标题和BGL标题和平共处?

回答

1

应该在询问前多点搜索epsilon。刚刚发布此之后,我发现这this page解释说,添加以下行包括可可头之前,将这样的伎俩:

#define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 

我曾试图这样做,在我个人MyAppDelegate.mm文件,它没有工作,但那是因为前缀头。将它添加到项目的前缀标题之前,它包含Cocoa/Cocoa.h做了窍门。