在iPhone 3G上协调错误?它可能是你的编译器 [英] Coordinates all wrong on iPhone 3G? It could be your compiler

查看:166
本文介绍了在iPhone 3G上协调错误?它可能是你的编译器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意:这是我已经找到答案的问题。似乎在找到有趣答案之后发布了一个问题, Apple开发人员论坛帖子指向问题在armv6由XCode 4.2编译器生成的Thumb代码中,该代码导致对某些数据结构的算术运算,特别是 CGPoint ,以返回完全错误的结果。例如将x值写入y值。



解决方案是添加 -mno-thumb XCode项目的编译器选项。这告诉编译器不要发出Thumb模式代码,从而绕过bug。另一个解决方案是切换回早期的XCode(iOS5之前的SDK),它没有这个bug。



所以bug在编译器中!多么酷啊? :)在二十年的开发过程中,我还没有遇到过这样的事情。



这是一个屏幕截图,显示如果它可以帮助任何人,可以在哪里添加这个编译器选项:




Note: This is question to which I have already found an answer. It seems that posting a question after finding an interesting answer is encouraged, so I am posting this. Someone else is likely to have the same problem and find this useful.


I have an iOS app that produces charts. Shortly after publishing an update, a user sent me this panicky email:

"the latest update has modified the curves ... not seen more growth curves and inserted data are represented as a line descending ... before you could see perfectly well

Help me"

I get him to send a screenshot and give more detail. He has an iPhone 3G and this is how girl's chart looks. Most points are drawn at the wrong coordinates: they appear to be drawn at (x,x) instead of (x,y).

Compare with how this is supposed to look (ignore the difference in colours -- pink is for girls, blue for boys):

After much experimentation, I send him a rebuilt version of the previous version (which worked OK for him) and it still doesn't work. So in the end it appears that the code changes in the update have nothing to do with it. What could be the explanation?

解决方案

iPhone original and iPhone 3G use the armv6 architecture, later models armv7. An answer to this Stack Overflow question, and an Apple developer forum thread point to a problem in the armv6 Thumb code produced by XCode 4.2's compiler which cause arithmetic operations on certain data structures, in particular CGPoint, to return completely wrong results. Such as the x value being written into the y value.

The solution is to add the -mno-thumb compiler option to the XCode project. This tells the compiler not to emit Thumb mode code, thereby bypassing the bug. Another solution is to switch back to an earlier XCode (pre-iOS5 SDK), which doesn't have this bug.

So the bug is in the compiler! How cool is that? :) In two decades of developing, I was yet to come across such a thing.

Here's a screenshot showing where to add this compiler option if it helps anyone:

这篇关于在iPhone 3G上协调错误?它可能是你的编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆