background picture of the home page

Think in Code

Linux修改、打包依赖路径(rpath)

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

Mac无边框无法最小化

将.cpp改为.mm 修改代码 #if __APPLE__ #include <unistd.h> #include <mach-o/dyld.h> #include <Cocoa/Cocoa.h> #endif void init_ui() { #if !__APPLE__ setWindo

thumbnail of the cover of the post