c++ Thread Anachronism Warning

Posted on 2005-05-12
Last Modified: 2013-12-26
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!


Question by:__Michael__
    LVL 23

    Expert Comment

    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)

    LVL 86

    Expert Comment

    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*);

    Author Comment

    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?
    LVL 86

    Expert Comment

    Have you tried to remove 'static' also?

    Author Comment

    Yes have also removed the static... same message with static removed.

    Author Comment

    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.

    Accepted Solution

    Closed, 500 points refunded.
    Community Support Moderator

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    Title # Comments Views Activity
    Add content to output file 4 54
    conditional code and condition difference 9 57
    only14 challenge 19 57
    sumHeights  challenge 17 50
    Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
    In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now