From a886e85965f1e8891b303c002014a890ab8383cc Mon Sep 17 00:00:00 2001 From: Bluemangoo Date: Fri, 14 Mar 2025 17:12:29 +0800 Subject: [PATCH] snippets --- .vscode/c.code-snippets | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.vscode/c.code-snippets b/.vscode/c.code-snippets index 5083568..e5479e0 100644 --- a/.vscode/c.code-snippets +++ b/.vscode/c.code-snippets @@ -9,16 +9,17 @@ "body": ["#define swap(a, b) { typeof(a) temp = a; a = b; b = temp; }"], "description": "Define function swap two var with macro" }, - "Define function swap two int": { - "prefix": "fn_swap", + "Define var swapper": { + "prefix": "fn_var_swapper", "body": [ - "void swap(int *a, int *b) {", - " int temp = *a;", - " *a = *b;", - " *b = temp;", - "}" + "#define SWAPPER(type, name) \\", + " void name(type *a, type *b) { \\", + " type t = *a; \\", + " *a = *b; \\", + " *b = t; \\", + " }" ], - "description": "Define function swap two int" + "description": "Define var swapper" }, "Define function put bool": { "prefix": "fn_putbool",