using usleep in c++ on diff platforms

Hi,

I'm using the command usleep (500000) when compiling C++ on the SunOS platform, but it does not compile on a OSF1 platform?
Any ideas?

Thanks

What error are you getting? I'll bet it's just that usleep() is not there.

It says that usleep is not defined
i.e.
line 1690: identifier "usleep" is undefined
usleep ( 500000 );

if I define it as an int then it compiles but the process does not actually sleep.

It's not enough to define it. You also need to write it.

Try using select(). I think OSF has that. See this post for an example.

Thanks for the help, I found what the problem was and for any future reference I have described it below:

In my header file I have a section the "ifdef OSF Platform" then add in extra defines that are not required on the sun platform. In this section I had to add in the line:

#define _XOPEN_SOURCE_EXTENDED

The result of this was that when the routine was called and accessed the unistd.h library file it activated the usleep routine (Which wasn't being activated before). Hence when I run the code it now sleeps as its supposed to!

Thanks for providing the solution to your problem instead of just saying, "I figured it out". :smiley: