问题描述
我想问一下在 Objective C 项目中使用FOUNDATION_EXPORT
而不是extern
的原因是什么.
I would like to ask what's the reason behind using FOUNDATION_EXPORT
instead of extern
in Objective C projects.
我已经检查了这个问题,并使用FOUNDATION_EXPORT
获得了高达340分(第一名),而仅使用extern
74分(第二名).
I've checked this question and using FOUNDATION_EXPORT
has earned whopping 340 points (1st place) whereas using extern
only 74 points (2nd place).
有人可以解释为什么吗?使用FOUNDATION_EXPORT
代替extern
有什么实际的理由吗?
Could anybody explain why? Is there any practical reason for using FOUNDATION_EXPORT
instead of extern
?
谢谢!
推荐答案
如果查看NSObjCRuntime.h(在Foundation中),您会看到FOUNDATION_EXPORT
在C中编译为extern
,在C ++中编译为extern "C"
,并且Win32中的其他内容.因此,它更具兼容性.对于大多数项目,这没有任何区别.
If you look in NSObjCRuntime.h (in Foundation) you will see that FOUNDATION_EXPORT
compiles to extern
in C, extern "C"
in C++, and other things in Win32. So, it's a bit more compatible. For most projects, this won't make any difference.
这篇关于"FOUNDATION_EXPORT"与“外部"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!