Stefan Zimmermann created THRIFT-3994:
-----------------------------------------

             Summary: Wrong pthread_t handling under MinGW
                 Key: THRIFT-3994
                 URL: https://issues.apache.org/jira/browse/THRIFT-3994
             Project: Thrift
          Issue Type: Bug
          Components: C++ - Library
         Environment: Windows, MinGW/[MSYS2|https://msys2.github.io], GCC 6.2.0
            Reporter: Stefan Zimmermann
            Priority: Blocker


Compiling {{7ab125a253e5aebbf2a0ed9a0a1602a4b879eca7}} under MinGW/MSYS2 with 
GCC 6.2.0:

{code}
src/thrift/concurrency/PosixThreadFactory.cpp: In member function 'virtual 
apache::thrift::concurrency::Thread::id_t 
apache::thrift::concurrency::PthreadThread::getId()':
src/thrift/concurrency/PosixThreadFactory.cpp:177:35: error: request for member 
'p' in 
'((apache::thrift::concurrency::PthreadThread*)this)->apache::thrift::concurrency::PthreadThread::pthread_',
 which is of non-class type 'pthread_t {aka long long unsigned int}'
     return (Thread::id_t)pthread_.p;
{code}

{code}
src/thrift/concurrency/PosixThreadFactory.cpp: In member function 'virtual 
apache::thrift::concurrency::Thread::id_t 
apache::thrift::concurrency::PosixThreadFactory::getCurrentThreadId() const':
src/thrift/concurrency/PosixThreadFactory.cpp:311:39: error: request for member 
'p' in 'pthread_self()', which is of non-class type 'pthread_t {aka long long 
unsigned int}'
   return (Thread::id_t)pthread_self().p;
{code}

Under MinGW, pthread_t is default POSIX, but {{_WIN32}} is defined, so the 
following pre-processor switches don't work correctly in this case:

{code}
  Thread::id_t getId() {

#ifndef _WIN32
    return (Thread::id_t)pthread_;
#else
    return (Thread::id_t)pthread_.p;
#endif // _WIN32
  }
{code}

{code}
Thread::id_t PosixThreadFactory::getCurrentThreadId() const {
#ifndef _WIN32
  return (Thread::id_t)pthread_self();
#else
  return (Thread::id_t)pthread_self().p;
#endif // _WIN32
}
{code}




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to