问题
Just upgraded to Lion and xcode 4.2. Now when I recompile my program I getting these errors:
/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)
There is nothing odd going on around those line numbers. No compound statements, just simple if (a == b)
type stuff. Some of the error line numbers aren't even on statements, just blank lines or a { brace. I suspect that the line numbers are not accurate. I'm kind of dead in the water now. Code compiled fine under 4.1.
Any advice?
回答1:
I stopped the compiler from crashing. After commenting out line after line of code to see where this was actually happening I arrived at this line:
shape.shapeType |= kTypeBreakable;
Doing...
shape.shapeType = shape.shapeType | kTypeBreakable;
...compiles fine. So does...
shape.shapeType |= 0x00000200;
kTypeBreakable
is an enum that is set to 0x00000200
shapeType
is just a obj-c object variable with a getter/setting.
Very very odd compiler bug.
来源:https://stackoverflow.com/questions/7762283/xcode-4-2-clang-seg-fault