[Xcode]非Objc文件(c, c++)引起的NSObjCRuntime错误解析
1.以下是错误示例
#if DEBUG
#define NSLog(FORMAT, ...) fprintf(stderr,"[%s:%d行] %s\n",[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat:FORMAT, ### #__VA_ARGS__] UTF8String]);
#else
#define NSLog(FORMAT, ...) nil
#import <Masonry.h>
#import "UIViewExt.h"
#endif
2.正确顺序
#import <Masonry.h>
#import "UIViewExt.h"
#if DEBUG
#define NSLog(FORMAT, ...) fprintf(stderr,"[%s:%d行] %s\n",[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat:FORMAT, ### #__VA_ARGS__] UTF8String]);
#else
#define NSLog(FORMAT, ...) nil
#endif
今天在objc工程中,导入一些c、c++文件时,,编译引起了NSObjCRuntime错误,,,仔细检查发现,
原来是在*.pch中,用上边错误的写法。调整顺序就可以正常编译了
网友评论