使用宏时隐式声明函数

时间:2016-06-07 13:46:19

标签: ios objective-c xcode

我正在尝试将自定义日志记录添加到我的objc应用程序中。目前它使用CocoaLumberjack。但我也希望在应用程序崩溃的情况下将日志发送到Crashlytics。所以我创建了一个带有宏的新头文件,看起来基本上是这样的:

#import <CocoaLumberjack/CocoaLumberjack.h>
#import <Crashlytics/Crashlytics.h>

#ifdef DEBUG
static const DDLogLevel ddLogLevel = DDLogLevelVerbose;
#else
static const DDLogLevel ddLogLevel = DDLogLevelWarning;
#endif

#define BKLogVerbose(frmt,...) DDLogVerbose(frmt, ##__VA_ARGS__)
#define BKLogDebug(frmt,...) DDLogVerbose(frmt, ##__VA_ARGS__)
#define BKLogInfo(frmt,...) DDLogInfo(frmt, ##__VA_ARGS__);\
                                CLS_LOG(frmt, ##__VA_ARGS__)
#define BKLogWarn(frmt,...) DDLogWarn(frmt, ##__VA_ARGS__);\
                                CLS_LOG(frmt, ##__VA_ARGS__)
#define BKLogError(frmt,...) DDLogError(frmt, ##__VA_ARGS__);\
                                CLS_LOG(frmt, ##__VA_ARGS__)

我正在导入此文件,我需要扩展日志记录:

#import "BKLogging.h"
...
BKLogError(@"%s, error: %@", __PRETTY_FUNCTION__, error);

但是当我尝试使用它时,我得到了:

Implicit declaration of function 'DDLogError' is invalid in C99

我理解编译器找不到DDLogError函数声明,但我不知道如何解决它(我想我需要将Crashlytics和CocoaLumberjack导入到使用BKLogging的每个文件中,但我想知道更好的解决方案)。

0 个答案:

没有答案