【发布时间】:2013-09-03 08:21:48
【问题描述】:
当设置了两个定义中的一个或两个时,我正在尝试禁用自动崩溃日志报告:DEBUG 用于我们的调试版本,INTERNATIONAL 用于国际版本。但是,当我尝试在 #ifndef 情况下执行此操作时,我收到警告 Extra tokens at end of #ifndef directive 并使用定义的 DEBUG 运行将触发 Crittercism。
#ifndef defined(INTERNATIONAL) || defined(DEBUG)
// WE NEED TO REGISTER WITH THE CRITTERCISM APP ID ON THE CRITTERCISM WEB PORTAL
[Crittercism enableWithAppID:@"hahayoudidntthinkidleavetherealonedidyou"];
#else
DDLogInfo(@"Crash log reporting is unavailable in the international build");
// Since Crittercism is disabled for international builds, go ahead and
// registers our custom exception handler. It's not as good sadly
NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);
DDLogInfo(@"Registered exception handler");
#endif
这个真值表显示了我的期望:
INTL defined | DEBUG defined | Crittercism Enabled
F | F | T
F | T | F
T | F | F
T | T | F
这在之前只是 #ifndef INTERNATIONAL 时有效。我也尝试过不使用 defined(blah) 并在整个语句周围加上括号(分别是相同的警告和错误)。
如何从编译器获得我想要的行为?
【问题讨论】:
标签: ios objective-c conditional-compilation