T
Tagore
# include<stdio.h>
#define NEG(a) -a
void main()
{
int x=1;
printf("%d",--1); //statement-1--This is compile time error.
printf("%d",-NEG(x)); //statement-2--It works and prints out 1
}
In statement-1 expectedly I am getting a compile time error as it is
trying to apply a decrement on a constant.
but in statement-2, I am not getting compiled error and gets result as
1.
I thought macro would expand as --1 and give an error.
Why is this anomaly in second statement?
#define NEG(a) -a
void main()
{
int x=1;
printf("%d",--1); //statement-1--This is compile time error.
printf("%d",-NEG(x)); //statement-2--It works and prints out 1
}
In statement-1 expectedly I am getting a compile time error as it is
trying to apply a decrement on a constant.
but in statement-2, I am not getting compiled error and gets result as
1.
I thought macro would expand as --1 and give an error.
Why is this anomaly in second statement?