On 05/16/2012 08:06 AM, rbmj wrote:
On 05/16/2012 07:26 AM, Janne Blomqvist wrote:
On Wed, May 16, 2012 at 1:03 PM, Tobias Burnus<bur...@net-b.de>  wrote:


On 05/16/2012 08:45 AM, Janne Blomqvist wrote:
IMHO it would be cleaner if you instead somewhere in the beginning of
unix.c did

#ifdef __VXWORKS__
/* open is not a variadic function on vxworks (or something...) */
#define open(path, flags) open(path, flags, 0666)
#endif

Untested, but AFAICS it should work (unless I'm missing something wrt
macro expansion, which of course is quite possible).

Testing shows that CPP does not like it:

$ cpp
#define a(x,y) a(x,y,0666)
a(1,2)
a(1,2,3)
# 1 "<stdin>"
# 1 "<command-line>"
# 1 "<stdin>"

a(1,2,0666)
<stdin>:3:8: error: macro "a" passed 3 arguments, but takes just 2
Ah, bummer. We have something roughly similiar for snprintf (see
libgfortran.h), but it seems that it works slightly differently due to
using a variadic macro etc. So it seems this idea will not work,
sorry.
Actually, this works for me:

$ cat test.c
#include <stdio.h>

void a(int b, int c, int d) {
   printf("%i\t%i\t%i", b, c, d);
}

#define a(b, c) (a)(b, c, 3)

int main() {
   a(1, 2);
   return 0;
}
$ gcc test.c -o a.out
$ ./a.out
1       2       3
Just realized that mine doesn't work either. Sorry, wasn't looking closely enough :-( The closest one can get is an inline overload, but that requires c++.

On a side note, isn't this what autoconf is designed for?

Robert Mason

Reply via email to