improve tk_swap

This commit is contained in:
lixianjing 2024-10-24 20:43:10 +08:00
parent dcc82626a3
commit 75e2e034a4
2 changed files with 9 additions and 5 deletions

View File

@ -1,5 +1,8 @@
# 最新动态
2024/10/24
* tk_swap防止临时变量重名(感谢兆坤提供补丁)
2024/10/23
* 修复mingw编译下font_stb_get_vmetrics异常问题(感谢颖健提供补丁)
* 增加tk_sha256_hash_from_str(感谢兆坤提供补丁)

View File

@ -409,9 +409,10 @@ typedef enum _ret_t {
#define tk_clampi(a, mn, mx) (int32_t)((a) < (mn) ? (mn) : ((a) > (mx) ? (mx) : (a)))
#define tk_swap(a, b, type) \
do { \
type temp = a; \
ENSURE(!tk_str_eq("_tEMP__", #a) && !tk_str_eq("_tEMP__", #b)); \
type _tEMP__ = a; \
a = b; \
b = temp; \
b = _tEMP__; \
} while (0)
#ifndef ARRAY_SIZE