CC (V5.8) compiler warning: pthread_create()

Hi Friends,

Recently we are facing some peculiar "warning" from our code where we call pthread_create() function.

Warning:

=============

"testMain.cpp", line 153: Warning (Anachronism): Formal argument 3 of type extern "C" void*(*)(void*) in call to pthread_create(unsigned*, const _pthread_attr*, extern "C" void*(*)(void*), void*) is being passed void*(*)(void*).

=============

Usage:

==============

void *delayFunction( void *ptr )

{

...........

}

pthread_t thread1;

int secs;

pthread_create( &thread1, NULL, delayFunction, (void*) &secs);

==========

We note that, this warning comes when we compile with CC (V 5.8) in solaris 5.9 machine, but does not occure when we compile with g++ compiler.

We unable to get the cause of the above warning.

If anyone have any solution of this, please let me know.

Regards,

Nilanjan

[957 byte] By [solaris_bitea] at [2007-11-27 9:07:45]
# 1
Perhaps delayFunction should be declared asextern "C" void *delayFunction( void *ptr );thanks,Dmitry
dmikha at 2007-7-12 21:44:53 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 2
Well, perhaps this does work around the problem but I would consider this a bug in the compiler since I don't see a reason why the compiler should take this into account at all when handling function pointers.
rschielea at 2007-7-12 21:44:53 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 3

According to C++ standard "Two function types with different language linkages are distinct types even if they are otherwise identical". extern "C" specifies C language linkage. In theory it is possible that C and C++ functions could have different calling conventions.

thanks,

Dmitry

dmikha at 2007-7-12 21:44:53 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 4
Ok, that convinced me. I was not aware of that rule.
rschielea at 2007-7-12 21:44:53 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 5
BTW. Discussion on similar topic can be found at http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/b6b cf80b9c86556b
dmikha at 2007-7-12 21:44:53 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 6
Hi Dmitry,It is working fine.Thanks
solaris_bitea at 2007-7-12 21:44:53 > top of Java-index,Development Tools,Solaris and Linux Development Tools...