在预处理器指令中包含静态库
Include static library within a preprocessor directive
我使用的是Visual Studio 2012。
我多次使用像 这样的预处理器指令#ifdef something
#include<some_header.h>
#else
#include<other_header.h>
#endif
我想知道是否有可能以类似的方式链接静态库:
#ifdef something
// use some_library.lib
#else
// use other_library.lib
#endif
这个问题来自于我之前的问题:我有两个静态库。自由,lib2。Lib(不是它们的代码),没有名称空间,具有相同的函数原型,但具有不同的实现。
如果您正在使用MSVC,您可以使用
#ifdef something
#pragma comment(lib,"xxx.lib")
#else
#pragma comment(lib,"zzz.lib")
#endif
相关文章:
- 在作为静态成员包含在另一个类中的类的构造函数中使用 cout
- 如果包含映射的静态库与可执行文件和动态库链接,静态映射(变量)是否会被多次释放?
- 将 C# 对象(包含静态对象成员)作为参数传递给 C++/CLI 程序
- 为什么具有静态存储持续时间的同一内联变量在包含在 VS2017 编译的两个翻译单元中时会构造和销毁两次
- 如果函数包含静态变量,为什么编译器不执行内联?
- 拒绝包含某些公共静态数据成员的类型
- 包含不同大小静态数组的类的多个实例
- 扩展包含静态函数的类
- 是否可以链接到,包括和使用静态库,而无需额外包含标头/文件
- 如何使用 mongo-cxx-driver 的 **insert** 函数将包含静态数据的多维数组插入到数据库中
- 为什么cmake_link_libraries包含静态库
- 如何在 MAC OS X 上的 CMAKE 项目中包含 C 静态库
- OpenCV和Visual Studio 2015:为什么包含静态库不起作用
- 纯抽象类可以包含静态常量、静态方法或非虚析构函数吗?
- c++无法为包含静态变量的对象设置NULL指针
- c++ 11是否允许非匿名联合包含静态数据成员?
- Caffe是否包含静态初始化失败?
- 如何在c++中强制包含静态库中的静态对象(msvc11)
- 在预处理器指令中包含静态库
- 头文件包含静态分析工具