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. for (; !Free; ) ; ????

for (; !Free; ) ; ????

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 Posts 4 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.
  • T Offline
    T Offline
    tongc
    wrote on last edited by
    #1

    for (; !Free; ) ; Free = FALSE; what does the for loop means! I only see for(; ; ) not the above. Thanks

    C J I 3 Replies Last reply
    0
    • T tongc

      for (; !Free; ) ; Free = FALSE; what does the for loop means! I only see for(; ; ) not the above. Thanks

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      it is the same as while(!Free) for (initialize ; test ; increment)


      "[it was..] one of those evenings when you feel that not only will there definitely be a revolution, but that the Association of Manufacturers will foot the bill." -- Umberto Eco, Foucault's Pendulum

      Smaller Animals Software

      1 Reply Last reply
      0
      • T tongc

        for (; !Free; ) ; Free = FALSE; what does the for loop means! I only see for(; ; ) not the above. Thanks

        J Offline
        J Offline
        Joaquin M Lopez Munoz
        wrote on last edited by
        #3

        As Chris pointed out, this is equivalent to

        while(!Free); //keep looping

        This makes little sense except in a multithreaded context where you're expecting some other thread to release a resource marked by Free. In fact, the snippet looks like a (very badly behaved) simulacre of EnterCriticalSection. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

        T 1 Reply Last reply
        0
        • J Joaquin M Lopez Munoz

          As Chris pointed out, this is equivalent to

          while(!Free); //keep looping

          This makes little sense except in a multithreaded context where you're expecting some other thread to release a resource marked by Free. In fact, the snippet looks like a (very badly behaved) simulacre of EnterCriticalSection. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

          T Offline
          T Offline
          tongc
          wrote on last edited by
          #4

          thanks!!!!

          1 Reply Last reply
          0
          • T tongc

            for (; !Free; ) ; Free = FALSE; what does the for loop means! I only see for(; ; ) not the above. Thanks

            I Offline
            I Offline
            ian mariano
            wrote on last edited by
            #5

            Watch that line! You've got a ; (semicolon) right after. You'll be in an endless loop, and Free will never get set to FALSE:

            while (TRUE == Free)
            {
            Free = FALSE;
            }

            Seems redundant, but I explicitly test for TRUE because who knows what magic numbers (#defined) mean.;P -- ian


            http://www.ian-space.com/

            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