Wednesday, 18 September 2013

Hows this macro working?

Hows this macro working?

#define MAX_T(a,b,d) \
{ int len = (d);printf("len %d", len);}
int main()
{
//MAX_T(10,30, smgarbage)
MAX_T(10,30, len)
}
I wrote this code in C
when i comment MAX_T(10,30, smgarbage) and run with output len 24
when i comment MAX_T(10,30, len) and run MAX_T(10,30, smgarbage) i get
this compiler error
test.c: In function 'main':
test.c:34: error: 'smgarbage' undeclared (first use in this function)
test.c:34: error: (Each undeclared identifier is reported only once
test.c:34: error: for each function it appears in.)
when executing MAX_T(10,30, len) why compiler error is not coming? Is
statement int len = (d); causing this? How?

No comments:

Post a Comment