问题描述
GCC 有能力通过 __attribute__((weak)) 弱化符号链接.我想在用户可以在其应用程序中覆盖的静态库中使用弱符号.GCC 风格的弱符号可以让我这样做,但我不知道是否可以用 Visual Studio 来完成.
GCC has the ability to make a symbol link weakly via __attribute__((weak)). I want to use the a weak symbol in a static library that users can override in their application. A GCC style weak symbol would let me do that, but I don't know if it can be done with visual studio.
Visual Studio 是否提供类似的功能?
Does Visual Studio offer a similar feature?
推荐答案
MSVC++ 有 __declspec(selectany) 它涵盖了弱符号的部分功能:它允许你定义多个相同的符号与外部链接,指示编译器选择几个可用的任何一个.但是,我认为 MSVC++ 没有任何东西可以涵盖弱符号功能的另一部分:在库中提供可替换"定义的可能性.
MSVC++ has __declspec(selectany) which covers part of the functionality of weak symbols: it allows you to define multiple identical symbols with external linkage, directing the compiler to choose any one of several available. However, I don't think MSVC++ has anything that would cover the other part of weak symbol functionality: the possibility to provide "replaceable" definitions in a library.
顺便说一句,这让人想知道对标准可替换 ::operator new 和 ::operator delete 函数的支持在 MSVC++ 中是如何工作的.
This, BTW, makes one wonder how the support for standard replaceable ::operator new and ::operator delete functions works in MSVC++.
这篇关于Visual Studio 中的 GCC 风格弱链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)