I tried the code below to trace the iterations of individual loops using a new variable ForloopCountM
. The code is working good for a loop within a loop and for a loop after another. but Macro is failing in below two cases, I need a help how can I fix this issue and track the iteration count.
void forloopTrace(int ForloopCount)
{
if( ForloopCount==50)
printf("Invalid \n");
}
#define CONCAT_IMPL( x, y ) x##y
#define MACRO_CONCAT( x, y ) CONCAT_IMPL( x, y )
#define FORlOOPCOUNTM MACRO_CONCAT(ForloopCountM,__LINE__)
#define for(args...)\
int FORlOOPCOUNTM=0;\
for(args,FORlOOPCOUNTM++,forloopTrace(FORlOOPCOUNTM))\
int main()
{
int i,j,x,y;
j=100;
y=200;
for(i=0;i<j;i) //works fine
{
i++;
for(x=0;x<y;x) //works fine
x++;
}
if(i>0)
for(;i>0;) //ERROR
i--;
for(;;) //Error
{
i++;
}
return 0;
}