Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualDan Mayor

Posted 14 February 2013 - 08:18 AM

Just for the sake of being nit picky I would use precompiler directives to separate the wait so that your not wasting a comparison tick every time you want to wait.

 

#ifdef WIN32

    system("pause");

#else

    system("sleep 1");

#endif

 

Using this method the compiler will only include the correct call for the correct system in which it is compiled on.  In real world applications Windows programs are packaged as compiled executable's 99% of the time and Linux is always in source form.  Making this calculation once at compile time vs once per execution (or more if you where to use this again somewhere) doesn't really save much of anything it just gets you in the habit of what I consider a better practice.

 

::Edit::

   I used #ifdef WIN32 because Microsoft's Visual Studio normally defines this for you by default when you have the sub system set to windows.  It could be defined as something different or you can use your own #define WINMODE or whatever you wish, just be sure that the compiler or the source have the correct platform defined for the build you are running.


#1Dan Mayor

Posted 14 February 2013 - 08:16 AM

Just for the sake of being nit picky I would use precompiler directives to separate the wait so that your not wasting a comparison tick every time you want to wait.

 

#ifdef WIN32

    system("pause");

#else

    system("sleep 1");

#endif

 

Using this method the compiler will only include the correct call for the correct system in which it is compiled on.  In real world applications Windows programs are packaged as compiled executable's 99% of the time and Linux is always in source form.  Making this calculation once at compile time vs once per execution (or more if you where to use this again somewhere) doesn't really save much of anything it just gets you in the habit of what I consider a better practice.


PARTNERS