Date: Wed, 28 Aug 2002 08:40:39 -0500 From: "Henning, Brian" <brian.henning@navitaire.com> To: " (E-mail)" <questions@FreeBSD.ORG> Subject: pthreads compiler warnings Message-ID: <E1846117A30764468D2192D5A48541CC03894D09@exchange.Navitaire.com>
next in thread | raw e-mail | index | archive | help
Hello- i am trying to run the following code but, when i do i get these errors. Am i linking to the wrong library or doing something wrong? I read the man pages and it said to use libc_r for a threaded user program. thanks, brian > gcc thread_example.c -lc_r /usr/lib/libc.so: WARNING! setkey(3) not present in the system! /usr/lib/libc.so: warning: this program uses gets(), which is unsafe. /usr/lib/libc.so: warning: mktemp() possibly used unsafely; consider using mkstemp() /usr/lib/libc.so: WARNING! des_setkey(3) not present in the system! /usr/lib/libc.so: WARNING! encrypt(3) not present in the system! /usr/lib/libc.so: warning: tmpnam() possibly used unsafely; consider using mkstemp() /usr/lib/libc.so: warning: this program uses f_prealloc(), which is not recommended. /usr/lib/libc.so: WARNING! des_cipher(3) not present in the system! /usr/lib/libc.so: warning: tempnam() possibly used unsafely; consider using mkstemp() #include <stdio.h> #include <pthread.h> #define NUM_THREADS 3 void *BusyWork(void *null) { int i; double result = 0.0; for( i = 0; i < 1000000; i++ ) { result = result + (double)random(); } printf("result = %d\n",result); pthread_exit((void *) 0); } int main( int argc, char *argv[] ) { pthread_t thread[NUM_THREADS]; pthread_attr_t attr; int rc, t, status; /* Initialize and set thread detached attribute */ pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); for( t = 0; t < NUM_THREADS; t++ ) { printf("Creating thread %d\n", t); rc = pthread_create(&thread[t], &attr, BusyWork, NULL); if (rc) { printf("ERROR; return code from pthread_create() is %d\n", rc); exit(-1); } } /* Free attribute and wait for the other threads */ pthread_attr_destroy(&attr); for( t = 0; t < NUM_THREADS; t++ ) { rc = pthread_join(thread[t], (void **)&status); if (rc) { printf("ERROR; return code from pthread_join() is %d\n", rc); exit(-1); } printf("Completed join with thread %d status= %d\n",t, status); } pthread_exit(NULL); return 0; } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E1846117A30764468D2192D5A48541CC03894D09>