将所有框架链接为可选 [英] Linking all frameworks as optional
问题描述
我阅读了此文档文章关于库和框架链接,下面的部分引起了我的注意:
I read this documentation article about library and framework linking and the section below drew my attention:
...仅在需要时才会加载可选框架.如果将不需要的大型库指定为Optional,则应用程序的初始加载会更快.
... an Optional framework will be loaded only if needed. The initial load of the application will be faster if a large library that is never needed is designated as Optional.
所以我问为什么不将所有框架都设置为 Optional
,如果它们在必要时会加载?缺点是什么?
So I'm asking why wouldn't I set all frameworks as Optional
, if they will load when necessary? What would be the drawback?
推荐答案
Using optional libraries requires additional code as it makes use of weak linking:
if (MyWeakLinkedFunction != NULL)
{
result = MyWeakLinkedFunction();
}
这使得使用该库有些痛苦;我宁愿知道该符号在程序加载时可用,如果不是,则O/S可以告诉用户.
That makes using the library something of a pain; I would rather know that the symbols are available when the program loads, and if they are not the O/S can deal with telling the user.
这篇关于将所有框架链接为可选的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!