我正在制作一个供多个可执行文件使用的 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/