MSYS2-packages icon indicating copy to clipboard operation
MSYS2-packages copied to clipboard

machine/_threads.h missing

Open P-p-H-d opened this issue 6 years ago • 4 comments

The standard C11 header threads.h provided by the package msys2-runtime-devel is not usable in msys2 due to missing header machine/_threads.h

For example the following program :

    #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L    \
      && !defined(__STDC_NO_THREADS__)
      
    #include <threads.h>
        
    #endif

$ gcc -c -std=c11 thread.c

    In file included from thread.c:4:0:
    /usr/include/threads.h:30:10: fatal error: machine/_threads.h: No such file or directory
     #include <machine/_threads.h>
              ^~~~~~~~~~~~~~~~~~~~
    compilation terminated.

Maybe defining the macro __STDC_NO_THREADS__ in some system headers to says that the header threads.h is not available is good enough.

P-p-H-d avatar Jan 04 '19 22:01 P-p-H-d

same problem

ghost avatar Jan 26 '20 19:01 ghost

Same problem, September 3, 2023. Was this never resolved?

bill-e-ghote avatar Sep 03 '23 15:09 bill-e-ghote

Works for me:

Markus@Markus-PC MSYS ~
$ cat thread.c
    #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L    \
      && !defined(__STDC_NO_THREADS__)

    #include <threads.h>

    #endif

Markus@Markus-PC MSYS ~
$ gcc -c -std=c11 thread.c

Markus@Markus-PC MSYS ~
$

mmuetzel avatar Sep 03 '23 15:09 mmuetzel

Works for me too:

saukrs@DESKTOP-O7JE7JE MINGW64 ~/src/c-tests/testing-headers-threads.h
$ cat thread.c
    #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L    \
      && !defined(__STDC_NO_THREADS__)

    #include <threads.h>

    #endif

saukrs@DESKTOP-O7JE7JE MSYS ~/src/c-tests/testing-headers-threads.h
$ gcc -c -std=c11 thread.c

saukrs@DESKTOP-O7JE7JE MSYS ~/src/c-tests/testing-headers-threads.h
$ echo $MSYSTEM
MSYS

saukrs@DESKTOP-O7JE7JE MSYS ~/src/c-tests/testing-headers-threads.h
$ uname -a
MSYS_NT-10.0-19044 DESKTOP-O7JE7JE 3.4.8.x86_64 2023-08-18 23:11 UTC x86_64 Msys

PS. And surely it doesn't in MINGW environment:

saukrs@DESKTOP-O7JE7JE MINGW64 ~/src/c-tests/testing-headers-threads.h
$ gcc -c -std=c11 thread.c
thread.c:4:14: fatal error: threads.h: No such file or directory
    4 |     #include <threads.h>
      |              ^~~~~~~~~~~
compilation terminated.

saukrs@DESKTOP-O7JE7JE MINGW64 ~/src/c-tests/testing-headers-threads.h
$ echo $MSYSTEM
MINGW64

(Saying just in case)

sskras avatar Sep 03 '23 16:09 sskras