2009-10-26 83 views
0

在我的iPhone项目中我使用了一些内联asm,如果目标架构是设备而不是模拟器,则不包括该内联asm。Xcode:构建特定于每个文件的编译器构建设置

由于一些内联asm代码只是arm而不是thumb,我需要在为iPhone编译时指定c标志-marm,因为否则它会用拇指指令编译代码。

这里是问题,如果我在文件中的特定构建设置进入-marm标志,GCC输出,如果我编译模拟器的错误:

cc1obj: error: unrecognized command line option "-marm"

有没有办法通过这个选项只如果目标架构是arm? 我知道你可以用全局c标志来做,但我不想用-marm标志编译我的整个项目。我只想要几个.m文件是-marm。

感谢和问候,金

+0

你看了生成日志,以确保在正确使用的选项时产生的Xcode从它的命令? – 2009-10-26 20:07:03

回答

0

好的我找到了解决这个问题的方法。

这里是我添加到代码的注释:

// the asm code only works with arm not with thumb, 
// so if you compile it and gcc trys to compile it as thumb 
// you will get an error. 
// to make gcc compile the file as arm and not thumb you need 
// to add -marm to the files compiler config (select the file 
// and press cmd + i and select the build tab and enter there 
// the problem is that if you try to compile for the simulator 
// it will fail, because intel gcc doesnt know the flat -marm. 
// To solve this add a new "User defined setting" in your targets 
// build settings with the name use_marm and give it the value "" 
// then add a build setting condition and select Any iPhone OS 
// Device and give it the value "-marm" 
// In your file's compiler flags add $use_marm 
// If you build for the device it will add -marm and if you 
// build for the simulator it wont.