问题描述
我编写了一个示例静态库。
我想抑制 std::string/std::wstring 的隐式实例化。我提到了这个 link 并且我声明了模板类 std::basic_string (外部模板)的显式实例化。我预计静态库不会包含 std::basic_string 的任何符号。但是 dumpbin 实用程序显示库中存在 basic_string 的符号。
代码如下:
// testLib.h
#pragma once
namespace staticLib{
void TestLib();
}
// testLib.cpp
#include < string >
#include "testLib.h";
//Explicit instantiation declaration
extern template class std::basic_string< char> ; // Is this correct?
namespace staticLib {
void TestLib() {
std::string str = "Testing";
str.size();
str.erase();
}
}
我的问题如下:
- 有没有办法抑制 std::string/std::wstring 的隐式实例化。
- 在 testLib.cpp 中有一个“std::basic_string 的显式实例化声明”。对吗?
- 为什么声明 basic_string 的显式实例化并不能阻止隐式实例化和库中的符号。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)