Comment on Was my decision to use C threads unwise?

Sonotsugipaa@lemmy.dbzer0.com ⁨1⁩ ⁨year⁩ ago

As far as I know, C’s threads.h implementation (or std::thread for C++) is based on POSIX threads.

If you’re using CMake or a similar build system that can define macros when building from Windows, then one option you have is to simply create an interface of sorts.
Something like:

// angle brackes work for this codeblock? idk

#ifdef PLATFORM_WIN32
   // The syntax MSVC wants (which I'm not familiar with)
   #include 
   thread_t win32_create_thread( /* ... */ ) {
      /* ... */
   }
#else
   // The syntax sensible compilers want (which I'm also unfamiliar with because I forgor U+1F480)
   #include 
   int thrd_create( /* ... */ ) {
      /* ... */
   }
#endif

It may be a bit tedious, but I don’t know if there is some widely known C equivalent to the Boost library, at least for threads.

source
Sort:hotnewtop