background picture of the home page

Think in Code

Linux修改、打包依赖路径

1. 通过环境变量修改 # 必须是绝对路径 export LD_LIBRARY_PATH=$(pwd) 2. 编译时指定rpath # 将rpath指定为当前目录 gcc test.c -L . -lhello -Wl,-rpath,'.' 3. 通过chrpath或patchelf修改 su

thumbnail of the cover of the post

C++实现Go中的defer

C++实现Go中的defer 原理:利用栈和析构 技巧: 利用__LINE__ 宏定义栈变量 利用C++变量名的就近原则,区分是否使用 init_defer_func_stack() 利用重载函数匹配规则,根据是否使用init_defer_func_stack,获取临时栈变量或者init_defer

thumbnail of the cover of the post

Goland中使用Makefile

Windows Goland使用Makefile 安装Chocolatey 管理员打开powershell 执行Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityPr

thumbnail of the cover of the post

字节序判断和转换

字节序判断和转换 #if _WIN32 #include <cstdlib> # define BYTE_SWAP_2(x) _byteswap_ushort(x) # define BYTE_SWAP_4(x) _byteswap_ulong(x)

thumbnail of the cover of the post

Qt进程单例

利用共享内存通信,第二次打开程序时,激活第一次打开的进程 #include <QApplication> #include <QSharedMemory> #include <QTimer> int main(int argc, char *argv[]) { QApplication a(ar

thumbnail of the cover of the post