K
Karim Thapa
Why following macro does not work?
#define removebrace(x) x
void Foo(int a, int b, char *txt, int d, int e);
main()
{
...
Foo(1, 2, removebrace(("hello", 5, 6)) );
...
}
I expected following expansion by compiler.
Foo(1, 2, "hello", 5, 6);
But it didnt work. When I see disassembly, only 3 arguments are pushed
into the stack, pointer to string "hello", value 2 and value 1 before
calling function 'Foo', instead of all 5 arguments.
However, if I do not use macro 'removebrace', all five arguments get
pushed to the stack before calling function 'Foo', and it works fine.
Any help, why MACRO removebrace does not work. I use MSVC 6.
Interestingly, this macro works fine in following statement
p = q * removebrace(a+b)
which results in
p = (q*a) + b
Karim
My previous post appeared to be lost so posting it again. Excuse me if
you receive two copy
#define removebrace(x) x
void Foo(int a, int b, char *txt, int d, int e);
main()
{
...
Foo(1, 2, removebrace(("hello", 5, 6)) );
...
}
I expected following expansion by compiler.
Foo(1, 2, "hello", 5, 6);
But it didnt work. When I see disassembly, only 3 arguments are pushed
into the stack, pointer to string "hello", value 2 and value 1 before
calling function 'Foo', instead of all 5 arguments.
However, if I do not use macro 'removebrace', all five arguments get
pushed to the stack before calling function 'Foo', and it works fine.
Any help, why MACRO removebrace does not work. I use MSVC 6.
Interestingly, this macro works fine in following statement
p = q * removebrace(a+b)
which results in
p = (q*a) + b
Karim
My previous post appeared to be lost so posting it again. Excuse me if
you receive two copy