how to build __builtin_va_arg_pack() example

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hello,
I wanted to try to learn a little bit more about these builtins (
https://gcc.gnu.org/onlinedocs/gcc-13.2.0/gcc/Constructing-Calls.html#index-_005f_005fbuiltin_005fva_005farg_005fpack
)

I tried to compile a small example, embedding the one from the
documentation:

#include <stdio.h>

extern int myprintf(FILE *f, const char *format, ...);
extern inline __attribute__((__gnu_inline__)) int myprintf(FILE *f, const
char *format, ...)
{
    int r = fprintf(f, "myprintf: ");
    if (r < 0)
        return r;
    int s = fprintf(f, format, __builtin_va_arg_pack());
    if (s < 0)
        return s;
    return r + s;
}
int main()
{
    myprintf(stdout, "ciao %d\n", 10);
    return 0;
}

I try to build with:

$ gcc -std=gnu2x -Wall test1.c -o test1
/usr/bin/ld: /tmp/ccrAlevM.o: in function `main':
test1.c:(.text+0x27): undefined reference to `myprintf'
collect2: error: ld returned 1 exit status
make: *** [makefile:88: test1] Error 1

Where am I going wrong?
regards
Max
-- 
Et nunc, auxilium solis, vincam!
Oppugnatio solaris!
VIS!

Massimiliano Cialdi



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux