B
Bill Pursell
I don't particularly enjoy using the va_start macro family, and I've
noticed that the following code works. I'm a little concerned about
the fact that the prototypes for foo do not match. Is this safe?
[tmp]$ cat q.c
extern int foo(int x,...);
int
main (int argc, char const*const* argv) /**/
{
foo(0);
foo(1,8);
foo(2,3,7);
foo(4,1,2,3,4);
return 0;
}
[tmp]$ cat r.c
int
foo(int num, int a, int b, int c)
{
switch(num) {
case 0: return 0;
case 1: return a;
case 2: return a+b;
case 3: return a+b+c;
default: return -1;
}
}
noticed that the following code works. I'm a little concerned about
the fact that the prototypes for foo do not match. Is this safe?
[tmp]$ cat q.c
extern int foo(int x,...);
int
main (int argc, char const*const* argv) /**/
{
foo(0);
foo(1,8);
foo(2,3,7);
foo(4,1,2,3,4);
return 0;
}
[tmp]$ cat r.c
int
foo(int num, int a, int b, int c)
{
switch(num) {
case 0: return 0;
case 1: return a;
case 2: return a+b;
case 3: return a+b+c;
default: return -1;
}
}