iOS:CocoaLumberjack:函数的隐式声明在c99中无效
问题描述:
我试图在我的应用程序框架中实现CocoaLumberjack,但我遇到了一些问题。这是我在我的AppDelegate.h实现:iOS:CocoaLumberjack:函数的隐式声明在c99中无效
#import "AppDelegate.h"
#import <CocoaLumberjack/CocoaLumberjack.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[DDLog addLogger:[DDASLLogger sharedInstance]];
[DDLog addLogger:[DDTTYLogger sharedInstance]];
DDFileLogger *fileLogger = [[DDFileLogger alloc] init];
fileLogger.maximumFileSize = 1024 * 1024;
fileLogger.rollingFrequency = 60 * 60 * 24; // 24 hour rolling
fileLogger.logFileManager.maximumNumberOfLogFiles = 7;
[DDLog addLogger:fileLogger];
DDLogWarn(@"blablabla");
DDLogError(@"Broken sprocket detected!");
DDLogVerbose(@"User selected file:%@ withSize:%u", @"temp/test/log.txt", 100000);
return YES;
}
在应用程序委托没有问题。但在我的ViewController:
- (void)viewDidLoad {
[super viewDidLoad];
DDLogError(@"something when wrong!!!"); // <-- implicit declaration of function is invalid in c99
}
我真的很感谢你的帮助。
答
添加以下行:
#define LOG_LEVEL_DEF ddLogLevel
#import <CocoaLumberjack/CocoaLumberjack.h>
见访问和配置Getting Started文件的框架部分。
+0
由于某些原因,它不起作用为了我。我修正了添加这个:#import
这意味着编译无法找到DDLogError的定义。你在viewcontroller.m文件中加入了可可伐木工头吗? – Byron
@Byron,我将这添加到viewController #import,它解决了C99错误,但现在我得到这个错误:“使用未声明的标识符ddloglevel” –
user2924482