刚刚升级到 Lion 和 xcode 4.2。现在,当我重新编译我的程序时,出现以下错误:
/Users/XXX/Code/iPhone/XXX/Code/Scenes/GameScene.mm:1806:35: current parser token ';'
/Users/XXX/Code/iPhone/XXX/Code/Scenes/GameScene.mm:1762:1: parsing Objective-C method 'updateWithTouchLocationMoved:withEvent:view:'
/Users/XXX/Code/iPhone/XXX/Code/Scenes/GameScene.mm:1762:1: in compound statement ('{}')
/Users/XXX/Code/iPhone/XXX/Code/Scenes/GameScene.mm:1771:2: in compound statement ('{}')
/Users/XXX/Code/iPhone/XXX/Code/Scenes/GameScene.mm:1789:3: in compound statement ('{}')
/Users/XXX/Code/iPhone/XXX/Code/Scenes/GameScene.mm:1796:4: in compound statement ('{}')
/Users/XXX/Code/iPhone/XXX/Code/Scenes/GameScene.mm:1799:5: in compound statement ('{}')
clang: error: unable to execute command: Segmentation fault: 11
clang: error: clang frontend command failed due to signal 2 (use -v to see invocation)
这些行号周围没有什么奇怪的。没有复合语句,只是简单的 if
(a == b)
类型的东西。一些错误行号甚至不在语句中,只是空行或 { 括号。我怀疑行号不准确。我现在有点死在水里了。代码在 4.1 下编译得很好。有什么建议吗?
最佳答案
我阻止了编译器崩溃。在逐行注释掉代码以查看实际发生的位置后,我到达了这一行:
shape.shapeType |= kTypeBreakable;
正在做...
shape.shapeType = shape.shapeType | kTypeBreakable;
...编译正常。也是...
shape.shapeType |= 0x00000200;
kTypeBreakable
是设置为 0x00000200
的枚举shapeType
只是一个带有 getter/setting 的 obj-c 对象变量。非常非常奇怪的编译器错误。
关于xcode4 - XCode 4.2 clang 段错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7762283/