0

What I am trying to do is to use threads.h from C11 standard on Windows 10. I had been installed Code::Blocks with MinGW. I've set in the Compiler Settings -std=c11 flag, but with no luck. I have been also installed a Win64 version of MinGW and I have set it as default with -std=c11 with no positive results also. I have downloaded the latest version of tdm-gcc and nothing changed.

All that I get is: fatal error: threads.h: No such file or directory

I know somebody that had been just installed the latest version of Code::Blocks and he has threads.h. I did it the same, but it seems that it doesn't work. I have read all the questions here, I almost know the responses and the comments just reading the first phrase in the question.

I found that Pelles C windows development kit has C11 standard available to use. The threads.h optional library is already integrated. I have been installed it, but I have a lot of GNU static libraries (.a) which should be compiled to Windows static or dynamic libraries, so it will be very time consuming.

Any help or any new information will be appreciated.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Mihai
  • 29
  • 1
  • 6
  • This is the first link when you search on google. It may be duplicate, but keep in mind that the marked answer was last edited in 2015. It is possible to not been implemented at that moment of time. Thank you! – Mihai Jun 12 '18 at 20:54
  • Maybe nothing has changed since 2015 w.r.t to ``? If you still think it isn't a duplicate, then you should certainly list the alternative and explain why you think this is not a duplicate of that. – Jonathan Leffler Jun 12 '18 at 22:53
  • 1
    It's interesting that Pelles C claims conformance to C17 when [ISO](https://www.iso.org/search.html?q=iso%2Fiec%209899&hPP=10&idx=all_en&p=0) still doesn't recognize it as a published standard. – Jonathan Leffler Jun 12 '18 at 22:58
  • Yes, you're right. I need this is for a project for faculty. I already asked my teacher how did he solved this problem, because he showed us some examples. He was not aware of it. He told me that he just installed Code::Blocks with MinGW. I think that maby there is still a problem regarding some CPUs or I dont know. I didn't found any documentation regarding this. – Mihai Jun 12 '18 at 23:06
  • IIRC, Code::Blocks uses whatever compiler(s) you tell it to use. So the issue is not so much which version of Code::Blocks (an IDE) your colleagues have; it is a question of which compiler they use, and which o/s they use. – Jonathan Leffler Jun 12 '18 at 23:19
  • You are right, it is about the last version of Code::Blocks with MinGW using TDM-GCC (version 5.1.0, 32 bit, SJLJ) on Windows operating system. It is really strange that the library threads.h works for him. I don't know which version of Windows is he using. Thank You! – Mihai Jun 12 '18 at 23:31

1 Answers1

1

TDM-GCC was last seen at 5.1.0 version (released 28th June 2015). They haven't updated their site or downloads since.

As for C11 threads themselves, they're an optional feature not necessary for the compiler vendor to provide. Test if __STDC_NO_THREADS__ is even present in your compiler. Then based on the tests try to include threads.h.

C11 threads functions are based off pthreads and most functions and structures are nearly a direct one-on-one mapping of POSIX threads interface.

So if you're inclined to still try C11 threads on Windows (because you're using TDM), I suggest you give it up now and use a slightly older but stable winpthreads library which provides nearly the same functionality. Upgrade your compiler to latest MingW-w64 to benefit from it.

Sadly, not C11 threads yet on Windows that I know of.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Unmanned Player
  • 1,109
  • 9
  • 30
  • I have already tried this macro-test: #if __STDC_NO_THREADS__ == 0 #include #else #error "No threading support" #endif The result is still "No such file or directory". – Mihai Jun 12 '18 at 23:09
  • @Mihai: That probably indicates that the implementation does not define `__STDC_NO_THREADS__` even though it does not implement ``. The standard can only say what a conforming compiler must do; non-conforming compilers can do whatever they like, and what they like is usually not what you, or the standards committee, would like. – Jonathan Leffler Jun 12 '18 at 23:15