문제

I have a project for iPhone configured to compile for armv6 and armv7 architectures. And I need to exclude some code from compiling for armv6 architecture because it causes runtime crash on device (bad instruction exception).

Is there a define for armv6/armv7 compilation paths (such as "_DEBUG")?

도움이 되었습니까?

해결책

First off, you don't need to prevent them from compiling, you need to prevent them from being executed. The crash is at runtime, after all, not compile time.

That said, the easiest way to do this is to have two code paths, and compile the appropriate section based on architecture:

#if defined _ARM_ARCH_7
// your armv7 implementation goes here
#elif defined _ARM_ARCH_6
// your armv6 implementation goes here
#elif defined __i386__
// a simulator implementation could go here, if you had one
#else
#error Unknown Architecture!
#endif

다른 팁

One workaround might be to gather all the armv6-only sources into a subproject and compile them as a static library, then link that library in to the fat application.

One can also specify additional build flags per source file in Xcode, but I'm not familiar with the syntax or what else would be required to essentially revert a flag already emitted (e.g., the flag to specify compiling under armv7.)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top