usleep() function


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


I tried to test the usleep() function that I found in the man page. I
included <unistd> per man page and the preprocessor complains that there is
no such file or directory. What am I doing wrong?

  unistd.h is not part of the C-C++ standard and, as the first error message
  indicates, 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