cross platfor sleep() ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jpenguin
    New Member
    • Aug 2007
    • 41

    cross platfor sleep() ?

    is tther a sleep() like function that use standard libraries that requires no change when moving from UNIX to Win. C++
  • thenath24
    New Member
    • Apr 2007
    • 10

    #2
    Originally posted by jpenguin
    is tther a sleep() like function that use standard libraries that requires no change when moving from UNIX to Win. C++
    Hi,

    Not done much cross-platform programming myself, but I beleive if you use the following tags your program should work;

    Code:
    #ifdef DOSMODE
    #include <io.h>
    #endif
    
    #ifdef UNIXMODE
    #include <unistd.h>
    #endif

    Comment

    • jpenguin
      New Member
      • Aug 2007
      • 41

      #3
      Originally posted by thenath24
      Hi,

      Not done much cross-platform programming myself, but I beleive if you use the following tags your program should work;

      Code:
      #ifdef DOSMODE
      #include <io.h>
      #endif
      
      #ifdef UNIXMODE
      #include <unistd.h>
      #endif
      Your advide told me what to loook for, google did the rest...

      Code:
      #ifdef _WIN32                      //includes dos.h only when
      #include <dos.h>                   //using the borland c++
      #endif                             //compiler [used for sleep()]
      
      #ifdef __unix__
      #include <time.h>                  //used for sleep() on *NIX-based systems
      #endif
      then I just used sleep(NUMBER_OF _SECS);

      Code:
      sleep(1);

      Comment

      • jpenguin
        New Member
        • Aug 2007
        • 41

        #4
        This helped me quite abit


        ---TOPIC CLOSED---

        Comment

        Working...