I have a Swift function doing something like this:
func f() -> Int {
switch (__WORDSIZE) {
case 32: return 1
case 64: return 2
default: return 0
}
}
Because __WORDSIZE
is a constant, the compiler always gives at least one warning in the switch body. Which lines are actually marked depends on the target I am building for (e.g. iPhone 5 vs. 6; interestingly iPhone 5 gives a warning for the 64-bit case whereas iPhone 6 gives two warnings for 32-bit and default).
I found out that the Swift equivalent for #pragma
is // MARK:
, so I tried
// MARK: clang diagnostic push
// MARK: clang diagnostic ignored "-Wall"
func f() -> Int {
switch (__WORDSIZE) {
case 32: return 1
case 64: return 2
default: return 0
}
}
// MARK: clang diagnostic pop
but the warnings remain, the MARK
s seem to have no effect.
As a workaround, I now have something like this:
#if arch(arm) || arch(i386)
return 1
#else
#if arch(arm64) || arch(x86_64)
return 2
#else
return 0
#endif
#endif
– but of course this is not the same. Any hints…?