Xcode 5.0 XCTest:宏“NULL”的不明确扩展

时间:2022-12-19 20:40:04

I'm using Xcode 5. I have a OS X Framework / iOS static library project with mixed ObjC/C++ code and language dialects set to C11/C++11.

我使用Xcode 5。我有一个OS X框架/ iOS静态库项目,混合ObjC/ c++代码和语言方言设置为C11/ c++ 11。

I added a Cocoa Unit Testing Bundle target which uses XCTest, I created one for both the iOS static library and the OS X framework.

我添加了一个Cocoa单元测试Bundle target,它使用XCTest,我为iOS静态库和OS X框架创建了一个。

This is the code I have and the error I get in both:

这是我的代码和我得到的两个错误:

-(void) testExample
{
    NSObject* world = [NSObject new];

    world = nil;  <--- Ambiguous expansion of macro 'NULL'
}

Running the iOS test the compiler tells me it is using the definition of NULL from stddef.h (line 74, ((void*)0)) and the other definition being in usr/include/stdlib.h (line 115, __DARWIN_NULL).

运行iOS测试,编译器告诉我它使用的是stddef中的NULL定义。h(第74行,(void*)0))和另一个定义在usr/include/stdlib中。__DARWIN_NULL h(第115行)。

The OS X test fails points to usr/include/MacTypes.h (line 90, __DARWIN_NULL) with this time the alternative being in stddef.h (line 74, ((void*)0)).

OS X测试失败指向usr/include/MacTypes。h(第90行,__DARWIN_NULL)这次替换为stddef。h(第74行,(0)(void *))。

Google has nothing on this issue. I'm just like "Well, I guess it's just one of these days...".

谷歌在这个问题上什么都没有。我只是说,“嗯,我想这只是其中的一个日子……”

Any clues as to what may be going on here, and how to fix it?

关于这里可能发生的事情,以及如何修复它,有什么线索吗?

UPDATE:

更新:

The iOS tests not running were due to creating the iOS unit test bundle with the OS X "Cocoa Unit Testing Bundle". /me slap

iOS测试不运行的原因是使用OS X“Cocoa单元测试包”创建了iOS单元测试包。/我耳光

The OS X testing issue persists though. But I have a hunch that being on OS X 10.9 (Mavericks) this may be related to a missing 10.9 SDK (Base SDK is set to 10.8).

OS X测试问题仍然存在。但我有个预感,在OS X 10.9 (Mavericks)上,这可能与丢失的10.9 SDK有关(基本SDK设置为10.8)。

2 个解决方案

#1


12  

In your Build Settings for your test target, try setting "Enable Modules" to NO.

在测试目标的构建设置中,尝试将“Enable Modules”设置为NO。

I've been having various kinds of trouble with test targets, all around preprocessor expansion. Doing this fixed things for me.

我一直有各种各样的测试目标的问题,围绕着预处理器扩展。这样做可以帮我解决问题。

#2


1  

Try this: Add -Wno-ambiguous-macro to Xcode -> Build Settings -> Other C Flags

试试这个:向Xcode添加- wno -歧义宏->构建设置->其他C标志

#1


12  

In your Build Settings for your test target, try setting "Enable Modules" to NO.

在测试目标的构建设置中,尝试将“Enable Modules”设置为NO。

I've been having various kinds of trouble with test targets, all around preprocessor expansion. Doing this fixed things for me.

我一直有各种各样的测试目标的问题,围绕着预处理器扩展。这样做可以帮我解决问题。

#2


1  

Try this: Add -Wno-ambiguous-macro to Xcode -> Build Settings -> Other C Flags

试试这个:向Xcode添加- wno -歧义宏->构建设置->其他C标志