Skip to content

Commit

Permalink
chore(docs): update function template docs for passing arguments to c…
Browse files Browse the repository at this point in the history
…allbacks as variable arguments
  • Loading branch information
Water-Melon committed Mar 7, 2024
1 parent 0bd0074 commit 829c769
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions docs/book/cn/func.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@
```c
void mln_func_entry_callback_set(mln_func_cb_t cb);

typedef void (*mln_func_cb_t)(const char *file, const char *func, int line);
typedef void (*mln_func_cb_t)(const char *file, const char *func, int line, ...);
```
描述:设置函数入口的回调函数。`mln_func_cb_t`的参数含义:
- `file` 函数所在文件
- `func` 函数名
- `line` 所在文件行数
- `...` 这里的可变参数为本回调函数的调用方函数的函数参数。这个参数只有在c99下才起作用。
返回值:无
Expand Down Expand Up @@ -191,12 +192,12 @@ MLN_FUNC(static, int, bcd, (int a, int b), (a, b), {
return abc(a, b) + abc(a, b);
})

static void my_entry(const char *file, const char *func, int line)
static void my_entry(const char *file, const char *func, int line, ...)
{
printf("entry %s %s %d\n", file, func, line);
}

static void my_exit(const char *file, const char *func, int line)
static void my_exit(const char *file, const char *func, int line, ...)
{
printf("exit %s %s %d\n", file, func, line);
}
Expand Down
7 changes: 4 additions & 3 deletions docs/book/en/func.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@
```c
void mln_func_entry_callback_set(mln_func_cb_t cb);

typedef void (*mln_func_cb_t)(const char *file, const char *func, int line);
typedef void (*mln_func_cb_t)(const char *file, const char *func, int line, ...);
```
Description: Set the callback function of the function entry. Parameter descriptions of `mln_func_cb_t`:
- `file` The file where the function is located
- `func` function name
- `line` is the number of lines in the file
- `...` The variable arguments are the function arguments of the calling function for this callback function. This parameter only works on c99.
Return value: None
Expand Down Expand Up @@ -187,12 +188,12 @@ MLN_FUNC(static, int, bcd, (int a, int b), (a, b), {
return abc(a, b) + abc(a, b);
})

static void my_entry(const char *file, const char *func, int line)
static void my_entry(const char *file, const char *func, int line, ...)
{
printf("entry %s %s %d\n", file, func, line);
}

static void my_exit(const char *file, const char *func, int line)
static void my_exit(const char *file, const char *func, int line, ...)
{
printf("exit %s %s %d\n", file, func, line);
}
Expand Down

0 comments on commit 829c769

Please sign in to comment.