iPhone 的汇编程序 (.s) 代码中的条件编译 - 如何? [英] Conditional Compilation in assembler (.s) code for iPhone - how?
问题描述
我在 .s 文件中有几行汇编器臂代码.只是我需要调用的一些例程.在为设备构建时它工作正常,但是当我切换到 iPhone 模拟器时,我收到没有这样的指令"错误.我试图用我所知道的有条件地编译 .s 文件的一部分:
I have a few lines of assembler arm code in an .s file. Just a few routines i need to call. It works fine when building for the device, however when i switch to iPhone Simulator i get "no such instruction" errors. I tried to compile parts of the .s file conditionally with what i know:
#if !TARGET_IPHONE_SIMULATOR
但是汇编器不识别这些预处理器指令(当然),并且我记得或找到的汇编器条件编译技术都没有,所以我现在正在抓紧关于如何避免编译该汇编器的问题为模拟器构建时的代码.我也没有在 Xcode 中看到允许我根据目标平台编译或不编译文件的项目选项.
But the assembler doesn't recognize these preprocessor directives (of course) and none of the conditional compilation techniques for assembler that i could remember or find worked, so i'm scratching my head now on how to avoid compilation of that assembler code when building for the Simulator. I also don't see a project option in Xcode that would allow me to compile the file or not depending on the target platform.
已解决:
我所缺少的只是汇编文件中正确的#import.我没有考虑添加它,因为 Xcode 语法以绿色(注释)突出显示了任何预处理器指令,这让我假设这些命令实际上工作得很好,但无法识别.
All i was missing was the proper #import in the assembler file. I did not think of adding it because Xcode syntax highlighted any preprocessor directive in green (comment) which made me assume that these commands are not recognized when in fact they work just fine.
这有效:
#import "TargetConditionals.h"
#if !TARGET_IPHONE_SIMULATOR
... asm code here ...
#endif
推荐答案
您可以使用预处理器宏来完成.它们在 TargetConditionals.h 中定义 TARGET_IPHONE_SIMULATOR
应该在那里!(不过,您确实需要 #include 它.)
You do do it with a pre-processor macro. They are defined in TargetConditionals.h TARGET_IPHONE_SIMULATOR
should be there! (You do need to #include it however.)
这篇关于iPhone 的汇编程序 (.s) 代码中的条件编译 - 如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!