ibireme / YYCache

High performance cache framework for iOS.
MIT License
2.37k stars 505 forks source link

问个问题,当工程中有time.h文件使用YYCache报错怎么处理 #20

Closed lianleven closed 8 years ago

lianleven commented 8 years ago

使用第三方的ffmpeg中有time.h文件,这样会和YYCache中使用的time()函数冲突,导致这样的错误 YYKVStorage.m:201:26: Implicit declaration of function 'time' is invalid in C99 Declaration of 'time' must be imported from module 'Darwin.C.time' before it is required ,我查看工程中ffmpeg中这个time.h并没有使用,暂时处理方式是删除这个time.h的引用。

问一下,有没有更好的处理方式 ?毕竟我的处理方式并不是一个真正解决问题的方法!

lianleven commented 8 years ago

补充一下,使用pod是没有问题的,使用文件导入的方式会出现上面问题。

ibireme commented 8 years ago

YYKVStorage 里面是这样写的:

#import <time.h>

这样应该是按照 Header search path 去搜索的,引入的应该是 /usr/include/time.h。

引入 ffmpeg 的头文件时,一般都应该带路径,比如 <ffmpeg/time.h> 或 "ffmpeg/time.h",这样不会和系统的头文件产生冲突了。你可以检查下 Header search path 相关的那几个参数,检查一下路径,并且避免用 recursive 搜索。

至于 pod 安装没问题,是因为 CocoaPods 会先在它单独的配置中编译这个库,所以不会引入项目头文件搜索路径。

lianleven commented 8 years ago

嗯嗯,重新引用,就好了。查看路径和你说的一样,很感谢。