public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* how to build __builtin_va_arg_pack() example
@ 2024-05-19 15:51 Massimiliano Cialdi
  0 siblings, 0 replies; only message in thread
From: Massimiliano Cialdi @ 2024-05-19 15:51 UTC (permalink / raw)
  To: gcc-help

[-- Attachment #1: Type: text/plain, Size: 1063 bytes --]

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-05-19 15:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-19 15:51 how to build __builtin_va_arg_pack() example Massimiliano Cialdi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).