Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-3994

Wrong pthread_t handling under MinGW

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • None
    • None
    • C++ - Library
    • None
    • Windows, MinGW/MSYS2, GCC 6.2.0

    Description

      Compiling 7ab125a253e5aebbf2a0ed9a0a1602a4b879eca7 under MinGW/MSYS2 with GCC 6.2.0:

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

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

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

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              zimmermann Stefan Zimmermann
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: