K&R-style variadic functions

Jacob Carlborg doob at me.com
Tue Jul 17 07:02:44 PDT 2012


On 2012-07-17 14:32, Regan Heath wrote:

>
> After a bit of googling and a test with my local MSVC9 I think old-style
> variadics look like this:
>
> #include <varargs.h>
> #include <stdio.h>
>
> void foo(va_alist)
>      va_dcl
> {
>      va_list p;
>      va_start(p);
>      vprintf("%d %d %d\n", p);
> }
>
> void main()
> {
>      foo(1, 2, 3);
> }
>
> (the above runs and outputs "1 2 3" on the console)
>
> The same syntax is/was supported by GNU C, see:
> http://ftp.gnu.org/old-gnu/Manuals/glibc-2.2.3/html_chapter/libc_34.html#SEC676
>
>
>
> I believe, if you see an "old-style" function declaration in a header
> file like:
>
>      int foo ();
>
> that you can't actually assume anything about it's parameters, it may
> have /any/ number of parameters, and may or may not be variadic.

Clang seems to interpret it as a variadic function. Then if that is 
correct or not I don't know.

-- 
/Jacob Carlborg




More information about the Digitalmars-d mailing list