【问题标题】:Getting LLVM error when building to device but not in simulator构建到设备但不在模拟器中时出现 LLVM 错误
【发布时间】:2011-07-28 08:37:41
【问题描述】:

当我尝试将测试目标构建到 iPad1 (4.3.5) 或 iPhone4 (4.3.5) 时,我从 Xcode 4 (Build 4A304a) 收到以下错误:

Internal compiler error: tree check: expected tree that contains 'decl with visibility' structure, have 'const_decl' in c_common_truthvalue_conversion

但不是在将测试目标切换到模拟器中构建时。

不正常的代码行是

GHAssertNotNULL(xxxObject, @"xxxObject could not be created");

(对象已被重命名以保护无辜者;-))但我可以说它是一个单例。

我搜索了谷歌并没有得到任何与此错误相关的信息。

提前致谢 伊恩。

【问题讨论】:

  • 在有人建议之前,我已经执行了 Product -> Clean。
  • 由于我在 6 个小时内无法回答自己的问题,因此这是我尝试提交的答案:-
  • 我想我已经回答了这个问题。最初,这是代表我的小学生错误。当返回的错误条件为 nil 时,我不应该测试 null。到目前为止听起来很容易。我更正了代码并再次编译。相同的错误,但场景大不相同,在 off_t 值和零之间执行 GreaterThan 比较(转换为 off_t)。长话短说,我怀疑这个问题与 32 v 64 位相关(分别在 iPad 和模拟器之间)。

标签: ios ios4 xcode4 llvm-gcc gh-unit


【解决方案1】:

我遇到了同样的编译器错误:

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)一起使用。请注意,为模拟器构建时没有问题。

编译器错误涉及对GHAssertNotEqualObjectsGHAssertNotEquals 的调用。

我收到编译器错误时使用的代码模式如下:

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

请注意,使用 const NSString(即 @"some string")对 GHAssertEqualObjectsGHAssertEqualStringsGHAssertEqualsGHAssertFalseGHAssertNilGHAssertNotNilGHAssertTrue 的调用不会导致编译器错误。

查看#define GHAssertNotEquals(a1, a2, description, ...)#define GHAssertEqualObjects(a1, a2, description, ...) 以及它们对description 的使用,两者都调用GHComposeString(description, ##__VA_ARGS__),但其他工作的宏也是如此。

【讨论】:

  • 谢谢!我遇到过同样的问题。我能够通过使用稍微不同的自定义断言宏来解决它。通过传递字符串常量指针,而不是在函数调用中内联它,我可靠地克服了这个问题。
猜你喜欢
  • 1970-01-01
  • 2017-07-31
  • 1970-01-01
  • 1970-01-01
  • 2014-07-09
  • 1970-01-01
  • 1970-01-01
  • 2014-07-25
  • 1970-01-01
相关资源
最近更新 更多