#1631 semaphore.h will not compile


Including semaphore.h fails with an error about missing mode_t. The problem can be exhibited with
#include <semaphore.h>

int main()
return 0;

Various work-arounds are possible. Including sys/stat.h before semaphore.h seems to provide the required definition.

This was reported as a problem when building Poly/ML on Mingw. It uses autoconf to detect the header files and includes semaphore.h if it is
present. It does not actually use semaphores on native Windows, instead using native Windows functions so I have worked around this by only
including semaphore.h if it going to be used.

David Matthews


  • Earnie Boyd

    Earnie Boyd - 2012-06-14

    This bug report belongs to pthreads-win32.

    <quote file=semaphore.h>
    * Module: semaphore.h
    * Purpose:
    * Semaphores aren't actually part of the PThreads standard.
    * They are defined by the POSIX Standard:
    * POSIX 1003.1b-1993 (POSIX.1b)
    * --------------------------------------------------------------------------
    * Pthreads-win32 - POSIX Threads Library for Win32

    However, I question whether or not these headers should be included in /mingw/include instead of /mingw/include/vendor directory? I've assigned to Cesar since these are included by installing GCC.

    The _mode_t data type is defined in sys/types.h and should be included by semaphore.h which is the bug.

  • Earnie Boyd

    Earnie Boyd - 2012-06-14
    • labels: 456608 --> non-mingw
    • milestone: --> Known_bugs
    • assigned_to: nobody --> cstrauss
  • Earnie Boyd

    Earnie Boyd - 2012-10-25

    Any comment Cesar?

  • Earnie Boyd

    Earnie Boyd - 2012-10-25
    • status: open --> pending
  • Earnie Boyd

    Earnie Boyd - 2013-02-11
    • labels: non-mingw --> gcc, pthreads
    • milestone: Known_bugs --> OTHER
    • type: --> Bug
    • resolution: --> none
    • category: --> Unknown
    • patch_attached: --> False

Log in to post a comment.