Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Difference between Debug and Release

Difference between Debug and Release

Scheduled Pinned Locked Moved C / C++ / MFC
debugginghelpquestionannouncementworkspace
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    masnu
    wrote on last edited by
    #1

    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.

    N P 2 Replies Last reply
    0
    • M masnu

      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.

      N Offline
      N Offline
      Nelek
      wrote on last edited by
      #2

      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?

      M 1 Reply Last reply
      0
      • M masnu

        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.

        P Offline
        P Offline
        prasad_som
        wrote on last edited by
        #3

        masnu wrote:

        While in the debug configuration this works without a problem but when I change to release and run the program it hangs. Any ideas?

        Refer this[^] article by Joseph M. Newcomer.


        Prasad MS MVP -  VC++

        M 1 Reply Last reply
        0
        • N Nelek

          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?

          M Offline
          M Offline
          masnu
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • P prasad_som

            masnu wrote:

            While in the debug configuration this works without a problem but when I change to release and run the program it hangs. Any ideas?

            Refer this[^] article by Joseph M. Newcomer.


            Prasad MS MVP -  VC++

            M Offline
            M Offline
            masnu
            wrote on last edited by
            #5

            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 wrote while (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 as volatile 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.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups