c++ - 以下哪种方法可以安全地导出到 C++ dll 中?

标签 c++ windows dll

我正在制作一个供多个可执行文件使用的 dll。我读过关于在接口(interface)上使用 STL 类的危险,我担心需要使用相同的编译器进行编译并使用相同的运行时运行。

如果导入它们的可执行文件可能使用不同版本的 VC++ 编译器和不同版本的 boost 进行编译,那么这些签名中的哪一个是声明我的方法的正确方法?

#include "boost/date_time/posix_time/posix_time_types.hpp"

boost::posix_time::ptime getTime();
void setTime(boost::posix_time::ptime time);

time_t getTime();
void setTime(time_t time);

MyCustomTime getTime(); // Defined just like time_t
void setTime(MyCustomTime time);

有没有更好的方法通过 dll 接口(interface)传递日期和时间结构?

最佳答案

只传递方便的内容,并记录所需的编译器/库。例如。无法保证不同的编译器具有相同的 time_t,并且由于 UNIX 32 位 time_t 在 2038 年溢出,您可以期待切换到 64 位 time_t 在某些时候。显然,这会破坏任何 DLL 接口(interface)。

关于c++ - 以下哪种方法可以安全地导出到 C++ dll 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15069695/

相关文章:

c++ - 根据 is_integer 转换为 int 或 float

C++通过引用传递常量值

string - OleVariant 可用于 DLL 过程中的输出参数吗?

windows - VB6 - 找不到 DLL

c++ - std::move 的用法

c++ - 数据隐藏,数据封装?实际应用

python - 您可以使用 Pyinstaller 访问多张照片吗?

c++ - 仅当部署在客户端时,Qt 5.9 的 SSL 握手问题

c# - 防止对话框在按钮的单击事件处理程序中关闭

c++ - 从 Windows 二进制文件中删除 msvcp90d.dll 依赖项