问题描述
GCC有使弱符号链接通过 __属性的能力__((弱))
。我想用一个弱符号,用户可以在自己的应用程序覆盖静态库。一个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.
这,顺便说一句,让人怀疑是如何的支持标准更换 ::运营商新的
和 :: delete操作符
函数工作在MSVC ++。
This, BTW, makes one wonder how the support for standard replaceable ::operator new
and ::operator delete
functions works in MSVC++.
这篇关于GCC风格的弱链接在Visual Studio?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!