[使用C ++进行Xcode单元测试:通过名称查找找到的候选对象是引用,并且引用不明确

问题描述 投票:0回答:1

我正在尝试将一些测试移入Xcode应用程序的XCTest目标。我要测试其功能的库很大,并且我将其头文件包含在tests.mm文件(所有单元测试用例所在的我的Obj-C ++测试文件)中。

对于一个特定的“ Size”类型,Compiler报告了一系列含糊的冲突,这些冲突的大小类型已经定义为MacOS10.13 SDK的一部分(在/ usr / include中)。这是我的测试文件的#include设置的样子:

#import <XCTest/XCTest.h>

#include <ql/quantlib.hpp>.   <---- defines Size, which clashes with MacTypes.h definition
#include <Analytics/all.hpp>
#include <boost/timer.hpp>
#include <utility>
#include <typeinfo>
#include <thread>
#include <atomic>
#include <mutex>
#include <random>
#include <condition_variable>
#include <future>

using namespace src::Utilities;
using namespace src::Simulation;
using namespace src::MarketData;
using namespace src::detail;
using namespace std::placeholders;

//...More code down here, but not problematic

是包含Size定义的文件。有人可以帮我找出哪里出了问题,尤其是当我作为巨型Main()函数的一部分运行测试时,一切正常。

感谢,胺

c++ xcode objective-c++
1个回答
0
投票

更新:经过一番研究,我认为我发现了这个问题的根源:在Objective-C ++测试框架中使用“使用命名空间xxxx”,而不是用xxxx ::完全限定数据类型与本机Apple API类型的冲突(大小,句柄,ptr等)。在这种情况下,需要使用C ++数据类型的完整名称空间限定,以避免产生歧义。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.