This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Threads !


On Tue, 2 May 2000, Anes Lihovac wrote:

> Hello !
> 
> I have one machine with egcs-2.91.66 and another machine running
> egcs-2.95.2.
> 
> A same application which is written in C++ which creates a Thread using
> the pthread
> function dosn't want to compile on the newer one.

When you report a bug, or any other difficulty with gcc, please report the
  full text of any error messages you recevied.

Next time, see http://gcc.gnu.org/bugs.html before reporting a bug.

> 
> I don't know if this is a bug !

It seems like a basic C++ question; it should have been asked in
  comp.lang.c++.moderated, or a similar forum.

> 
> Thanks and best regards
> 
> code snippet:
> 
> 
> void function::myClass()
> {
> 	...
> 	...
> }
> 
> void doSomething::myClass()
> {
> 	pthread_t thread;
> 
> 
> 	pthread_create(&thread,NULL,(void*)function,(void*)this); 

I cannot tell if this is legal C++; your 'code snippet'  leaves out too
  much.

  If 'function' is a namespace, it is definitly not legal. 

  If 'function' is a class, and there is also a function declared as 
  'void* function(void*)' (legal, but bad practice), it will compile, but
  it may not do what you expect.

Note that function pointers and member function pointers are very
  different beasts, and pthread_create() wants a function pointer.

> }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]