[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1101
  • Last Modified:

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!


1 Solution
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)

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*);
__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?
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Have you tried to remove 'static' also?
__Michael__Author Commented:
Yes have also removed the static... same message with static removed.
__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.
Closed, 500 points refunded.
Community Support Moderator

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now