473,387 Members | 1,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

Chris M. Thomasson wrote:
>
"Ian Collins" <ia******@hotmail.comwrote in message
news:6m*************@mid.individual.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_VER)
# 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
Oct 27 '08 #1
1 1798

"Ian Collins" <ia******@hotmail.comwrote in message
news:6m*************@mid.individual.net...
Chris M. Thomasson wrote:
>>
"Ian Collins" <ia******@hotmail.comwrote in message
news:6m*************@mid.individual.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_VER)
# 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...

Oct 28 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Tseng, Ling-hua | last post by:
As the comments of the following C++ code, I got the ambiguous error in the specialized class " PThreadTimer<void *(*)(void *)> ". I performed the virtual inheritance mechanism on its base classes...
9
by: David A. Osborn | last post by:
I have a set of classes that each have an enumeration in them, and based on dynamic input I need to access a different enumeration. For example Three classes Class_A, Class_B, and Class_C that...
0
by: hecklar | last post by:
I'm having a problem with threading (permissions?) in a VB.net Windows application (background service). I'm trying to write an application that processes files, launching a new thread for each...
5
by: Martin Jørgensen | last post by:
Hi, Consider this code: --- beginning of code --- #include <iostream> using namespace std; class Child{ public:
7
by: WXS | last post by:
Vote for this idea if you like it here: http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=5fee280d-085e-4fe2-af35-254fbbe96ee9...
4
by: jayesah | last post by:
Hi All, I am writting a Thread class with using pthread library. I have some problem in saving thread function type and argument type. How to make Thread class generic ? /* This is my global...
9
by: Steve Richter | last post by:
in a generic class, can I code the class so that I can call a static method of the generic class T? In the ConvertFrom method of the generic TypeConvert class I want to write, I have a call to...
0
by: JoelKatz | last post by:
On Oct 27, 10:55 am, alexroat <alexr...@gmail.comwrote: Really? What do you get with this code: #include <stdio.h> #include <pthread.h> class Thread {
1
by: Chris M. Thomasson | last post by:
FWIW, here is a quick example (in the form of a fully compliable program with error checking omitted) of how I use POSIX threads within a C++ environment:...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.