Thank you for the report. However, we would propose the following patch (making sure that "theThread" is really of type "void *").
Code: Select all
--- libsrc/ofthread.cc 4 Jun 2010 14:18:20 -0000 1.19
+++ libsrc/ofthread.cc 18 Jun 2010 07:44:30 -0000
@@ -1,6 +1,6 @@
/*
*
- * Copyright (C) 1997-2010, OFFIS
+ * Copyright (C) 2000-2010, OFFIS
*
* This software and supporting documentation were developed by
*
@@ -137,17 +137,21 @@ int OFThread::start()
{
#ifdef WINDOWS_INTERFACE
unsigned int tid = 0;
- theThreadHandle = _beginthreadex(NULL, 0, thread_stub, (void *)this, 0, &tid);
+ theThreadHandle = _beginthreadex(NULL, 0, thread_stub, OFstatic_cast(void *, this), 0, &tid);
if (theThreadHandle == 0) return errno; else
{
+#ifdef HAVE_POINTER_TYPE_PTHREAD_T
+ theThread = OFstatic_cast(void *, tid);
+#else
theThread = tid;
+#endif
return 0;
}
#elif defined(POSIX_INTERFACE)
pthread_t tid=0;
int result = pthread_create(&tid, NULL, thread_stub, OFstatic_cast(void *, this));
#ifdef HAVE_POINTER_TYPE_PTHREAD_T
- if (0 == result) theThread = tid; else theThread = 0;
+ if (0 == result) theThread = OFstatic_cast(void *, tid); else theThread = 0;
#else
if (0 == result) theThread = OFstatic_cast(unsigned long, tid); else theThread = 0;
#endif
@@ -196,7 +200,11 @@ OFBool OFThread::equal(unsigned long /*
#endif
{
#ifdef WINDOWS_INTERFACE
+#ifdef HAVE_POINTER_TYPE_PTHREAD_T
+ if (theThread == OFstatic_cast(void *, tID)) return OFTrue; else return OFFalse;
+#else
if (theThread == tID) return OFTrue; else return OFFalse;
+#endif
#elif defined(POSIX_INTERFACE)
#ifdef HAVE_POINTER_TYPE_PTHREAD_T
// dangerous - we cast an unsigned long back to a pointer type and hope that it is still valid
@@ -416,7 +424,7 @@ OFSemaphore::OFSemaphore(unsigned int /*
: theSemaphore(NULL)
{
#ifdef WINDOWS_INTERFACE
- theSemaphore = (void *)(CreateSemaphore(NULL, numResources, numResources, NULL));
+ theSemaphore = OFstatic_cast(void *, CreateSemaphore(NULL, numResources, numResources, NULL));
#elif defined(POSIX_INTERFACE)
sem_t *sem = new sem_t;
if (sem)
@@ -553,7 +561,7 @@ OFMutex::OFMutex()
: theMutex(NULL)
{
#ifdef WINDOWS_INTERFACE
- theMutex = (void *)(CreateMutex(NULL, FALSE, NULL));
+ theMutex = OFstatic_cast(void *, CreateMutex(NULL, FALSE, NULL));
#elif defined(POSIX_INTERFACE)
pthread_mutex_t *mtx = new pthread_mutex_t;
if (mtx)
I've tested the above patch (based on the current DCMTK snapshot) on a Linux system with gcc 4.1 and under Windows with VS 2008. Could you please test it with your MinGW system and let us know whether it also works. Thanks in advance!