bug-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

g++3.0.3 problem with sleep()


From: Stewart Cambridge London, UK
Subject: g++3.0.3 problem with sleep()
Date: 20 Jun 2002 02:54:19 -0700

I've seen one other post about this (by James Shen
(address@hidden)) on 23 Jan 2002

Running gcc version 3.0.3
Running g++ version 3.0.3

sample code:

#include <stdio.h>
#include <unistd.h>
int main() {
  printf("Before\n");
  sleep(3);
  printf("After\n");
  return 0;
}

$ gcc -c sleep_test.c
No problems! But...
$ g++ -c sleep_test.c
gives....
sleep_test.c: In function `int main()':
sleep_test.c:8: `sleep' undeclared (first use this function)
sleep_test.c:8: (Each undeclared identifier is reported only once for
each
   function it appears in.)

I tried changing header stuff to....
#include <stdio.h>
//#include <unistd.h>
extern unsigned int sleep(unsigned int);

int main() {
....
}

Now....
$ g++ -c sleep_test.c
No problems! But instead a linking error...
$ g++ -o sleep_test sleep_test.c
/var/tmp/ccAAEjqL.o: In function `main':
/var/tmp/ccAAEjqL.o(.text+0x18): undefined reference to
`sleep(unsigned)'
collect2: ld returned 1 exit status

Anyone up for a guess at a solution??

Stewart



reply via email to

[Prev in Thread] Current Thread [Next in Thread]