__Michael__
asked on
c++ Thread Anachronism Warning
I am trying to comple a library on Solaris 7 that is used to contoll custom boards and drivers.
I get the following warning:
"Thread.cpp", line 30: 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*).
It is complaining wbout the following peice of code:
if (pthread_create(&m_id, &m_attr, startThread, this))
throw tds_InternalError("pthread _create failed");
I am unsure why this warning is showing up. I haved looked at many forums... with no answer.
This is the only warning i have in the compile. When i try and run a test program that uses the library it seg faults.
Could this be because of this error or in the actual drivers?
Help to resolve this warning will great!
Regards,
Michael
I get the following warning:
"Thread.cpp", line 30: 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*).
It is complaining wbout the following peice of code:
if (pthread_create(&m_id, &m_attr, startThread, this))
throw tds_InternalError("pthread
I am unsure why this warning is showing up. I haved looked at many forums... with no answer.
This is the only warning i have in the compile. When i try and run a test program that uses the library it seg faults.
Could this be because of this error or in the actual drivers?
Help to resolve this warning will great!
Regards,
Michael
It seems that your compiler is a bit picky about the linkage - make sure your thread func is declared as
extern "C" void startThread(void*);
extern "C" void startThread(void*);
ASKER
The func is declared as:
static void *startThread(void *object);
I tried adding the extern "C" dec however this created errors stating "Error: Linkage specifications are allowed only at file level"
Any other reccomendations?
static void *startThread(void *object);
I tried adding the extern "C" dec however this created errors stating "Error: Linkage specifications are allowed only at file level"
Any other reccomendations?
Have you tried to remove 'static' also?
ASKER
Yes have also removed the static... same message with static removed.
ASKER
Ok managed to fix the problem myself. The problem lied in the fact the the code was not compatible with SUN CC 5.5, thus I included the /opt/SUNWspro/lib/CC4 and used the -compat=4 flag.
Pretty sure this makes the code compile under SUN CC 4.2. It has compiled with no errors ow warnings.
Thankyou for your help.
Pretty sure this makes the code compile under SUN CC 4.2. It has compiled with no errors ow warnings.
Thankyou for your help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
startThread does not conform to the prototype void *(*)(void*).
In other words, startThread must be defined as
void * startThread(void *arg)