[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [MiNT] GCC question
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 2010-11-17 13:58, Helmut Karlowski wrote:
> #define x(y) (xy,y)
> #define y(a,b,c,d) (d,c,b,a)
>
> y(1,2,x(X))
>
>
> while gcc complains.
In my opinion gcc is correct:
y(1,2,x(X)) -> y(1,2,(xX,X))
gcc cannot evaluate the statement because the fourth parameter for the y
macro is missing. A quick test:
+++
thomas@mac tmp 62: cat foo.c
#include <stdio.h>
#define x(y) (xy,y)
#define y(a,b,c,d) (d,c,b,a)
int main(int a, char* b[])
{
printf("Hello world! %d %d %d %d\n", y(1, 2, x(3)));
return 0;
}
thomas@mac tmp 63: gcc -Wall -o foo foo.c
foo.c:10:55: error: macro "y" requires 4 arguments, but only 3 given
foo.c: In function ‘main’:
foo.c:10: error: ‘y’ undeclared (first use in this function)
foo.c:10: error: (Each undeclared identifier is reported only once
foo.c:10: error: for each function it appears in.)
+++
Cheers,
Thomas
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkzlEJUACgkQMiyRSD9s+zURTwCdFhIHB3I0yFUrYkzZol/1CvMJ
+0IAnR49IHErjdGcgITPvmF2RbTJmC5t
=41wj
-----END PGP SIGNATURE-----