导入.pch文件和.h文件的顶部? [英] import in .pch file and top of .h file?

查看:54
本文介绍了导入.pch文件和.h文件的顶部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是obj-c的新手.我注意到的是.pch文件用于包含整个x代码项目中的文件,但随后在某些.h文件的顶部也包含了相同的文件,例如#import,这是什么.将其重新导入到.h文件顶部(如果该文件已经包含在.pch文件中)的原因?

I'm new to obj-c. Something I've noticed is that the .pch file is used to include files across the whole x-code project, but then the same files are also included as well at the top of some .h files, #import for example, what's the point importing it again at the top of a .h file if it's already included in the .pch file?

推荐答案

预编译头文件的目的是为了加快编译速度,而不是保存输入内容.如果由于已在预编译头文件中"而省略了导入,则将该同一个文件复制到恰好具有不同预编译头文件集的另一个项目中,它将失败.对于< Foundation/Foundation.h> 这样的常见导入不太可能,但是我已经看到其他导入也发生了这种情况.

The purpose of precompiled headers is to speed compilation, not to save typing. If you omit an import because "it's already in the precompiled headers," then copy that same file to a different project which happens to have a different set of precompiled headers, it will fail. This isn't likely for common imports like <Foundation/Foundation.h>, but I've seen it happen with other imports.

请参见 4种预编译头破坏代码的方式.

这篇关于导入.pch文件和.h文件的顶部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆