naseeam
asked on
Why "for" loop expression has no effect ?
We used Keil tools to compile our embedded c++ code.
for ( i = 0, idx_reg_curr = j ; i < 10, idx_reg_curr < (j+10) ; i++, idx_reg_curr++ )
In above for loop, I get the following compile warning:
warning: #174-D: expression has no effect
Why doesn't this expression has effect ?
for ( i = 0, idx_reg_curr = j ; i < 10, idx_reg_curr < (j+10) ; i++, idx_reg_curr++ )
In above for loop, I get the following compile warning:
warning: #174-D: expression has no effect
Why doesn't this expression has effect ?
i < 10, idx_reg_curr < (j+10)
exchange the expression by
i < 10 || idx_reg_curr < (j+10)
if you want to have both counters to be below the upper boundary.
otherwise you may use logical &&.
note, the , (comma) allows to execute two statements. but putting a comma in a logical expression has no effect. the compiler only would check the first expression.
Sara
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Problem solved and explained very quickly. Thank you very much!
ASKER
Open in new window