条件编译汇编(.S)code的iPhone - 怎么样? [英] Conditional Compilation in assembler (.s) code for iPhone - how?

查看:520
本文介绍了条件编译汇编(.S)code的iPhone - 怎么样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有汇编手臂code在一个.s文件的几行。就在几个套路,我需要打电话。建设设备时,但是当我切换到iPhone模拟器我得到没有这样的指令的错误它工作正常。我试图编译.s文件的部分有条件与我知道的:

 #如果!TARGET_IPHONE_SIMULATOR

但是,汇编程序不承认这些preprocessor指令(当然),没有的条件编译技术汇编,我记得还是找工作,所以我抓我的头,现在就如何避免编译建设模拟器时汇编code的。我还没有看到X code进行项目的选择,让我到编译文件,或者不考虑在目标平台上。

解决:

所有我缺少的是在汇编文件正确的#import。我不认为加入它,因为X code语法突出显示为绿色(评论)任何preprocessor指令,它让我假设而事实上,他们的工作只是罚款这些命令不被识别的。

本作品:

 #进口TargetConditionals.h#如果!TARGET_IPHONE_SIMULATOR... ASM code这里...#万一


解决方案

您做一个pre处理器宏做到这一点。它们在TargetConditionals.h定义 TARGET_IPHONE_SIMULATOR 应该在那里! (您确实需要但需要#include它。)

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

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.

SOLVED:

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.

This works:

#import "TargetConditionals.h"

#if !TARGET_IPHONE_SIMULATOR

... asm code here ...

#endif

解决方案

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.)

这篇关于条件编译汇编(.S)code的iPhone - 怎么样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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