Quantcast
Channel: Tools
Viewing all articles
Browse latest Browse all 91752

Forum Post: RE: IF statement compiles incorrectly

$
0
0

Your code fragment has undefined behavior because you are writing to Sched_0_Fctn_Ctr twice between sequence points.  That is, it is not legal C code.  You need to write it like this:

if (Sched_0_Fctn_Ctr >= CYCLE_SCHED_0 )          Sched_0_Fctn_Ctr = 0;      else Sched_0_Fctn_Ctr++;

or like this if you intended the increment to come first:

Sched_0_Fctn_Ctr++; if (Sched_0_Fctn_Ctr >= CYCLE_SCHED_0 ) Sched_0_Fctn_Ctr = 0;

[ Edited after posting -- Archaeologist ]


Viewing all articles
Browse latest Browse all 91752

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>