ICYMORN | 寒霜之晨
诗与编程

在看 https://tell-k.github.io/pyconjp2018/ 的时候,看到有一个库挺有意思的,叫做 atexit,是一个内置的库,主要用来处理程序退出时的工作。 以下例子抄自:https://pymotw.com/3/atexit/ , 比如可以这样用: import atexit def all_done(): print('all_done()') ...

随手翻译了一下,原文来自:https://www.aristeia.com/Papers/DDJ_Jul_Aug_2004_revised.pdf 介绍 你应该在很多地方用过单例模式,在很多语言中,像 js,python 这些可以利用模块本身的特性实现单例。但是到了 C++ 这边,就需要考虑额外的东西:单例模式需要考虑线程安全。 当然,最典型一个解决方案是 Double-Checked...

将二进制文件硬编码进代码可以一定程度上防止模型文件泄露,不过如何嵌入是一个需要考虑的点。 我在 github 上看到有这样做: std::string string_to_hex(const std::string &in) { std::stringstream ss; ss << std::hex << std::setfill('0');...

代码来自:http://programanddesign.com/cpp/human-readable-file-size-in-c/ char* readable_fs(double size/*in bytes*/, char *buf) { int i = 0; const char* units[] = {"B", "kB", "MB", "GB", "TB", "...

在编译好一个 C++ 库后,我并没有把它安装到用户目录 /usr/local/bin,而是手动指定了一个目录: make install DESTDIR=../install 然而这时候到目录中运行可执行文件时就出现了一个问题: dyld: Library not loaded: @rpath/AAA.dylib Referenced from: AAA_EXE Reason...