What's wrong with this simple thread example?

From: jsmithe8 (jsmithe8_at_NOSPAM.netscape.net)
Date: 09/21/04


Date: Tue, 21 Sep 2004 12:15:52 +1000

Does anyone know what's wrong with this code, I'm trying to get threads to
work on redhat linux. It won't compile.

Thanks in advance.
#include <unistd.h>

#include <pthread.h>

#include <stdio.h>

#include <sys/types.h>

#define _REENTRANT

pthread_t thr_a, main_thr;

void* a(void* arg){

printf("Thread a");

pthread_exit ((void *)main_thr);

}

void main(){

int junk;

main_thr = pthread_self();

if (pthread_create(&thr_a,NULL, a, NULL))

printf("Can't create thr_a\n");

}



Relevant Pages

  • Re: menu-based console application
    ... typedef void; ... struct MenuEntry ... Compile everything, fix typing errors and run the program. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: CFile and FILE*
    ... ever call exit() in any C++ ... LPVOID, e.g., ... void DoSomething ... Note that you can still compile this as C ...
    (microsoft.public.vc.mfc)
  • Re: A non-const reference may only be bound to an lvalue?
    ... To my surprise, I have tested that the following code can compile, ... struct X { ... void f; ... There are legitimate reasons to want to do that, but I've come to accept it ...
    (microsoft.public.vc.language)
  • Re: Library bug or my fault?
    ... void memcpy ... struct Foo { ... 29 void cp(const Foo *foo) ... You have no definition for cp2so the code above won't compile. ...
    (comp.lang.c)
  • SUMMARY: void main(int argc, char *argv[]) question
    ... The consensus is that the use of void on main is wrong (The book ... return and int. ... >In trying to compile some old test Unix C programs... ... Why do those old UNIX programs used void ... ...
    (SunManagers)