项目中使用了FMDatabase,编译发现一个错误”Implicit declaration of function ‘NSFileTypeForHFSTypeCode’ is invalid in C99”,
这是FMDB的问题,FMDatabaseAdditions.m中存在如下一段代码:我们需要在代码的外面做预编译:
#if TARGET_OS_MAC && !TARGET_OS_IPHONE // 添加预编译处理
- (NSString*)applicationIDString {
NSString *s = NSFileTypeForHFSTypeCode([self applicationID]);
assert([s length] == 6);
s = [s substringWithRange:NSMakeRange(1, 4)];
return s;
}
- (void)setApplicationID:(uint32_t)appID {
NSString *query = [NSString stringWithFormat:@"PRAGMA application_id=%d", appID];
FMResultSet *rs = [self executeQuery:query];
[rs next];
[rs close];
}
- (void)setApplicationIDString:(NSString*)s {
if ([s length] != 4) {
NSLog(@"setApplicationIDString: string passed is not exactly 4 chars long. (was %ld)", [s length]);
}
[self setApplicationID:NSHFSTypeCodeFromFileType([NSString stringWithFormat:@"'%@'", s])];
}
#endif // 结束