K&R-style variadic functions

Lukasz wrzoski at gmail.com
Tue Jul 17 13:28:53 PDT 2012


I was sure that if function is declared with empty () than you 
can call it with any arguments you imagine, as it is in following 
examples.
============================= ex. 1
<*> cat main.c
void a() {
}

int main()
{
     a(1, 2, 3);
     return 0;
}

<*> gcc -Wall -Wextra -pedantic  main.c
<*>

============================== ex. 2
<*> cat test.c
#include <stdio.h>
void a(int a, char b, void* ptr)
{
     printf("%d  %c  %p\n", a, b, ptr);
}

<*> cat main.c
extern void a();

int main()
{
     int aa = 123;
     char b = '#';
     void* ptr = (void*)0xffaaffaa;
     a(aa, b, ptr);
     return 0;
}

<*> gcc -c test.c
<*> gcc -c main.c
<*> gcc -o main main.o test.o
<*> ./main
123  #  0xffaaffaa
<*>

But this is not:



More information about the Digitalmars-d mailing list