M
miloody
dear all:
below is my source code.
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
int index;
int idx0=0;
for(index=0;index<1024;index++)
{
idx0 = (++idx0)%2;
printf(" %d\n",idx0);
}
return 1;
}
and I compile it with following commands
"gcc -Wall -g -O1 -o test test.c"
but the warning say:
test.c: In function "main":
test.c:12: warning: operation on "idx0" may be undefined
I split it by line 10 and line 11, and they go fine.
why does the operation in line 12 get warning?
Thanks for your help in advance,
miloody
below is my source code.
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
int index;
int idx0=0;
for(index=0;index<1024;index++)
{
idx0 = (++idx0)%2;
printf(" %d\n",idx0);
}
return 1;
}
and I compile it with following commands
"gcc -Wall -g -O1 -o test test.c"
but the warning say:
test.c: In function "main":
test.c:12: warning: operation on "idx0" may be undefined
I split it by line 10 and line 11, and they go fine.
why does the operation in line 12 get warning?
Thanks for your help in advance,
miloody