Difference between Debug and Release
-
I have an application that is writing data to a serial port. To allow all the data to be written before I do anything else I use
while( pCom->tx_in_progress ){;}
. While in the debug configuration this works without a problem but when I change to release and run the program it hangs. Any ideas? Thanks. -
I have an application that is writing data to a serial port. To allow all the data to be written before I do anything else I use
while( pCom->tx_in_progress ){;}
. While in the debug configuration this works without a problem but when I change to release and run the program it hangs. Any ideas? Thanks.Hi do you have initial values in your parameters? Are you checking them before going into the loop. In debug the variables get values alone, but in release not. There are more messages about this problem in forum, take a look with search option :)
Greetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
-
I have an application that is writing data to a serial port. To allow all the data to be written before I do anything else I use
while( pCom->tx_in_progress ){;}
. While in the debug configuration this works without a problem but when I change to release and run the program it hangs. Any ideas? Thanks. -
Hi do you have initial values in your parameters? Are you checking them before going into the loop. In debug the variables get values alone, but in release not. There are more messages about this problem in forum, take a look with search option :)
Greetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
I am initializing the variable when I instantiate my class. The problem seems to be in the while loop. If I turn off optimization, or just have the default, for my release configuration it runs. When I optimize for "maximum speed" the program hangs. It must be how the compiler is dealing with the "empty" while loop. Any ideas? Thanks.
-
Thanks Prasad (and Joseph). I found the answer in his article. For those who are curious the problem came about in the declaration of tx_in_progress. It was declared as
int tx_in_progress
. When I wrotewhile (pCom->tx_in_progress) {;}
and optimized for speed the compiler assumed nothing in the loop modified the variable so it never checked it again, creating an endless loop. The solution is to declare it asvolatile int
which tells the compiler not to make any assumptions about the variable. I'm pretty sure that is the cause of it. If anyone has something different please let me know. Great article by Joseph. Thanks.