views:

632

answers:

1

Hello,

in my iPhone project I am using some inline asm, which is excluded if the target architecture is the device and not the simulator.

Since some of the inline asm code is arm only and not thumb I need to specify the c flag -marm when compiling it for the iPhone, since it otherwise trys to compile the code with the thumb instructions.

And here is the problem if I enter the -marm flag in the file specific build setting, gcc outputs an error if I compile for the simulator:

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

Is there a way to pass this option only if the target architecture is arm? I know you can do it with the global c flags, but I dont want to compile my whole project with the -marm flag. I want only a few .m files to be -marm.

Thanks and greetings, Kim

A: 

OK I found a solution for the issue.

Here is the comment I added to the code:

// 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.
Kim