volatile int typecast return value. Could this make problem?

Hello experts, I'm a beginner of embedded system development.

I have question.about difference of two code.

at first, suppose there is function like

   int SomeFunction(void) {

      ......

       return (some integer);

}

And using this function return value like these

  • int retval;

       retval = SomeFunction();

       if (retval == {some Variable})  {

         . . .

       }

  • if ( {some Variable} == (volatile int) SomeFunction()) {

          ....

        }

    

former one doesn't make any problem, but when i used like latter one.. some times, retval is not correct and some strange value remains on r0 register...;

I don't know what is problem on latter one exactly...;

Could explain what is the problem of these?

Thank you very much for reading this..... though it is written by pool english...

Parents Reply Children
No data
More questions in this forum