How are variable arguments implemented in gcc?

后端 未结 4 554
无人及你
无人及你 2020-11-27 04:51
int max(int n, ...)

I am using cdecl calling convention where the caller cleans up the variable after the callee returns.

I a

4条回答
  •  余生分开走
    2020-11-27 05:28

    int max(int n, const char *msg,...)
    {
    va_list args;
    char buffer[1024];
    va_start(args, msg);
    nb_char_written = vsnprintf(buffer, 1024, msg, args);
    va_end(args);
    printf("(%d):%s\n",n,buffer);
    }
    

提交回复
热议问题