473,385 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

cross platfor sleep() ?

is tther a sleep() like function that use standard libraries that requires no change when moving from UNIX to Win. C++
Nov 13 '07 #1
3 3104
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;

Expand|Select|Wrap|Line Numbers
  1.  
  2. #ifdef DOSMODE
  3. #include <io.h>
  4. #endif
  5.  
  6. #ifdef UNIXMODE
  7. #include <unistd.h>
  8. #endif
  9.  
  10.  
Nov 13 '07 #2
Hi,

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

Expand|Select|Wrap|Line Numbers
  1.  
  2. #ifdef DOSMODE
  3. #include <io.h>
  4. #endif
  5.  
  6. #ifdef UNIXMODE
  7. #include <unistd.h>
  8. #endif
  9.  
  10.  
Your advide told me what to loook for, google did the rest...

Expand|Select|Wrap|Line Numbers
  1. #ifdef _WIN32                      //includes dos.h only when
  2. #include <dos.h>                   //using the borland c++
  3. #endif                             //compiler [used for sleep()]
  4.  
  5. #ifdef __unix__
  6. #include <time.h>                  //used for sleep() on *NIX-based systems
  7. #endif
then I just used sleep(NUMBER_OF_SECS);

Expand|Select|Wrap|Line Numbers
  1. sleep(1);
Nov 14 '07 #3
This helped me quite abit


---TOPIC CLOSED---
Nov 14 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Anks | last post by:
hi I am displaying a digital clock in an applet.I am using Thread.sleep (1000) for counting every second.This works fine some times but some times my clock just slows down or give an...
7
by: Colin Brown | last post by:
Python 2.3.3 Under Windows NT: Negative Int or Real -> sleeps for a long time Under Linux: Returns IOError: Invalid argument I consider both of these unfriendly results and expected the...
5
by: Dave | last post by:
For the life of me, I thought there was a sleep() function in the Standard Library (or something similarly named), but I can't find it. Is it non-existent or, if not, what header is it in? ...
17
by: OlafMeding | last post by:
Below are 2 files that isolate the problem. Note, both programs hang (stop responding) with hyper-threading turned on (a BIOS setting), but work as expected with hyper-threading turned off. ...
15
by: Bryce K. Nielsen | last post by:
I have an object that starts a thread to do a "process". One of the steps inside this thread launches 12 other threads via a Delegate.BeginInvoke to process. After these 12 threads are launched,...
0
by: Leo Jay | last post by:
i have a development board based on s3c2410 arm cpu. and i want to port python on it. after googling some threads, i successfully cross compiled python. but i still encountered a weird issue that...
7
by: atlaste | last post by:
Hi, I have two different things I'd like to discuss here. Both are about cross-process synchronization of shared resources. The resources that are shared are: (1) an object writing to a file and...
13
by: Charles Zhang | last post by:
Sleep() function Sleep at lease 1 millisecond, there is a way to make a thread to sleep less than a millisecond? One way I know of is using performance counter which is not really sleep ( loop and...
3
by: yeye.yang | last post by:
hey everybody Does everybody can help me or give me some advise for the cross thread exception catch Here is what I want to do: I have 2 classes "Scenario" and "Step", which have a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.