A Person
A Person

Reputation: 811

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

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.

Upvotes: 2

Views: 1071

Answers (1)

Stephen Canon
Stephen Canon

Reputation: 106287

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

Upvotes: 3

Related Questions