Forward an invocation of a variadic function in C

前端 未结 12 2439
悲哀的现实
悲哀的现实 2020-11-22 06:41

In C, is it possible to forward the invocation of a variadic function? As in,

int my_printf(char *fmt, ...) {
    fprintf(stderr, \"Calling printf with fmt %         


        
12条回答
  •  悲哀的现实
    2020-11-22 07:07

    If you don't have a function analogous to vfprintf that takes a va_list instead of a variable number of arguments, you can't do it. See http://c-faq.com/varargs/handoff.html.

    Example:

    void myfun(const char *fmt, va_list argp) {
        vfprintf(stderr, fmt, argp);
    }
    

提交回复
热议问题