开发者

How to choose between compiling ARM assembly file if iOS device and using regular C if iOS simulator

开发者 https://www.devze.com 2023-03-28 02:13 出处:网络
In one of projects I have a file written in ARM assembly that uses NEON to optimize a calculation I am doing it. I also have a file that does the exact same thing except that it is written in C. Curre

In one of projects I have a file written in ARM assembly that uses NEON to optimize a calculation I am doing it. I also have a file that does the exact same thing except that it is written in C. Currently I just comment out the C functions that are开发者_如何学编程 being defined in assembly and just add a

extern void myFunction();

to the C file. What i would like to do is have this in the C file

#ifdef device
extern void myFunction();
#else
void myFunction() {
   /* code here */
}
#endif

I would also need something similar in the assembly file but im not sure how to do preprocessor directives in ARM assembly.

So to sum all this up im looking for a preprocessor definition that tells me what device im am building for and a way to use preprocessor directives in assembly.


In your C file:

#if defined __arm__
extern void myFunction();
#else
void myFunction() {
   /* code here */
}
#endif

In your assembly file:

#if defined __arm__
/* code here */
#endif

(Xcode applies the C preprocessor to .s files as well).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号