Visual Studio 2017, How to make #include work?

后端 未结 4 2292
长情又很酷
长情又很酷 2021-02-08 05:31

I feel like I\'ve been searching for hours today on how to make #include work in Visual Studio 2017 on Windows 10 and haven\'t come across an answ

4条回答
  •  日久生厌
    2021-02-08 06:26

    Windows doesn't natively support pthreads.

    There is an implementation of pthreads for Windows you could use. If you're just trying to get some code running on Windows ASAP it may be your best bet.

    If you can modify the code, you might want to take a look at what pthread functions you are actually using; if all you need is a mutex a few #ifdefs around pthreads/winapi may be a better way to go.

    There are also some projects which implement compatibility layers that aren't as expressive as the full pthreads API, but are more than enough for most projects. TinyCThread is one option (which I maintain, so take the recommendation with a grain of salt) which implements the C11 threads API.

    Other options include:

    • GLib
    • libuv

    OpenMP could also be a good choice. It is really easy to use, but operates at a higher level and so it may require a more substantial rewrite.

提交回复
热议问题