预处理程序表达式Xcode开头的令牌无效 [英] Invalid token at start of a preprocessor expression Xcode

查看:112
本文介绍了预处理程序表达式Xcode开头的令牌无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#define A7VERSION() ({[[[[[UIDevice currentDevice] systemVersion] componentsSeparatedByString:@"."] objectAtIndex:0] intValue];})

#define IS_OS_7 A7VERSION()>=7

上面的声明似乎编译得很好。

The above declaration seems to compile well.

但是,一旦我将其添加为.m文件,就会收到以下异常预处理器表达式开始时无效的令牌。我无法理解哪里可能出错

But as soon as I add it a .m file I get the following exception "invalid token at start of a preprocessor expression". I am not able to understand where I could be wrong

@implementation AppViewController
#if IS_OS_7
….
#else
….  
#endif
@end


推荐答案

问题与iOS 7无关。

The problem has nothing to do with iOS 7.

您的 #define 不会导致某些问题。在编译时解决。 #ifdef 仅在条件是可以在编译时确定的条件下起作用。不能根据应用运行的环境在运行时更改行为。

Your #define does not lead to something that can be resolved at compile time. An #ifdef only works if the conditional is something that can be determined at compile time. It cannot be used to change behavior at runtime based on the environment an app is running on.

这篇关于预处理程序表达式Xcode开头的令牌无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆