Re: Question on C++ Thread Class and inheritance/polymorphism withPOSIX pthread

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ian Collins

    Re: Question on C++ Thread Class and inheritance/polymorphism withPOSIX pthread

    Chris M. Thomasson wrote:
    >
    "Ian Collins" <ian-news@hotmail.co mwrote in message
    news:6mmgf1Fgdr 8lU11@mid.indiv idual.net...
    >alexroat wrote:
    >>private:
    >> static void * gate(void *);//access point for pthread_create
    >>
    >This should be an extern "C" linkage function, not a static member.
    >
    [...]
    >
    Yes. Humm... Well, FWIW, I guess one can take advantage of compiler
    specific extensions here. It's a dirty thing, but I think it would work.
    Something like:
    >
    #if defined(_MSC_VE R)
    # define DECLSPEC_CDECL __cdecl
    #elif defined(__GNUC_ _)
    # define DECLSPEC_CDECL __attribute__(( cdecl))
    #else
    # error MSVC or GCC REQUIRED!!!!! ;^(...
    #endif
    >
    Why bother with all that nonsense when there is a standard solution?

    --
    Ian Collins
  • Chris M. Thomasson

    #2
    Re: Question on C++ Thread Class and inheritance/polymorphism with POSIX pthread


    "Ian Collins" <ian-news@hotmail.co mwrote in message
    news:6mmqrkFgdr 8lU17@mid.indiv idual.net...
    Chris M. Thomasson wrote:
    >>
    >"Ian Collins" <ian-news@hotmail.co mwrote in message
    >news:6mmgf1Fgd r8lU11@mid.indi vidual.net...
    >>alexroat wrote:
    >
    >>>private:
    >>> static void * gate(void *);//access point for pthread_create
    >>>
    >>This should be an extern "C" linkage function, not a static member.
    >>
    >[...]
    >>
    >Yes. Humm... Well, FWIW, I guess one can take advantage of compiler
    >specific extensions here. It's a dirty thing, but I think it would work.
    >Something like:
    >>
    >#if defined(_MSC_VE R)
    ># define DECLSPEC_CDECL __cdecl
    >#elif defined(__GNUC_ _)
    ># define DECLSPEC_CDECL __attribute__(( cdecl))
    >#else
    ># error MSVC or GCC REQUIRED!!!!! ;^(...
    >#endif
    >>
    Why bother with all that nonsense when there is a standard solution?
    Agreed. However, using the non-standard compiler specific hack can eliminate
    the "need" to use a base-class for the thread class. The extern "C"
    free-function has no idea what type what will be passed to it. This is not
    the case for the hack version...

    Comment

    Working...