GCC风格的弱链接在Visual Studio? [英] GCC style weak linking in Visual Studio?

查看:689
本文介绍了GCC风格的弱链接在Visual Studio?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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