usleep() function


R. Clayton (rclayton@monmouth.edu)
(no date)


The man page says usleep() is defined in unistd but when I include <unistd> the
preprocessor complains that there is no such file or directory. What is wrong?

  If you look closely at the man page, you'll see it says usleep is defined in
  unistd.h, which is not part of the C-C++ standard and should not be used with
  the standard include syntax:

    $ cat bad.cc
    #include <unistd>

    int main(){
      usleep(27);
      }

    $ g++ -c bad.cc
    t.cc:1:18: unistd: No such file or directory
    t.cc: In function `int main()':
    t.cc:4: `usleep' undeclared (first use this function)

    $ cat good.cc
    #include <unistd.h>

    int main(){
      usleep(27);
      }

    $ g++ -c good.cc

    $



This archive was generated by hypermail 2.0b3 on Mon Dec 16 2002 - 22:00:05 EST