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
__Michael__Asked:
Who is Participating?
 
PashaModCommented:
Closed, 500 points refunded.
PashaMod
Community Support Moderator
0
 
brettmjohnsonCommented:
What is the definition of startThread()?  The warning states that
startThread does not conform to the prototype void *(*)(void*).
In other words, startThread must be defined as

void * startThread(void *arg)

0
 
jkrCommented:
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*);
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
__Michael__Author Commented:
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?
0
 
jkrCommented:
Have you tried to remove 'static' also?
0
 
__Michael__Author Commented:
Yes have also removed the static... same message with static removed.
0
 
__Michael__Author Commented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.