我遇到了同样的编译器错误:
internal compiler error: tree check: expected tree that contains 'decl with visibility' structure, have 'const_decl' in c_common_truthvalue_conversion, at c-common.c:2836
为 iOS 设备构建时,将 Xcode 4.1 与 GHUnitIOS-0.4.32(和 GHUnitIOS-0.4.31)一起使用。请注意,为模拟器构建时没有问题。
编译器错误涉及对GHAssertNotEqualObjects
和的调用GHAssertNotEquals
。
我收到编译器错误时使用的代码模式如下:
- (void) test_isEqual {
SomeObject *foo = [[SomeObject alloc] initWithValue: 1];
SomeObject *bar = [[SomeObject alloc] initWithValue: 2];
GHAssertNotEquals(bar, foo, @"Different Objects, different values - different pointers");
GHAssertNotEqualObjects(bar, foo, @"Different Objects, different values - different pointers (calls isEqual)");
}
我能够通过以下修改编译代码:
- (void) test_isEqual {
NSString *comment;
SomeObject *foo = [[SomeObject alloc] initWithValue: 1];
SomeObject *bar = [[SomeObject alloc] initWithValue: 2];
comment = @"Different Objects, different values - different pointers";
GHAssertNotEquals(bar, foo, comment);
comment = @"Different Objects, different values - different pointers (calls isEqual)";
GHAssertNotEqualObjects(bar, foo, comment);
}
请注意,调用GHAssertEqualObjects
, GHAssertEqualStrings
, GHAssertEquals
, GHAssertFalse
, GHAssertNil
,GHAssertNotNil
和GHAssertTrue
使用 const NSString,即 @"some string",不会导致编译器错误。
研究#define GHAssertNotEquals(a1, a2, description, ...)
and#define GHAssertEqualObjects(a1, a2, description, ...)
和他们的使用description
,都调用GHComposeString(description, ##__VA_ARGS__)
,但其他宏也是如此。