• 0 Posts
  • 23 Comments
Joined 1 year ago
cake
Cake day: June 16th, 2023

help-circle

















  • 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 "fuckmissingbracketsidontrememberwhatiwrotehere"
       thread_t win32_create_thread( /* ... */ ) {
          /* ... */
       }
    #else
       // The syntax sensible compilers want (which I'm also unfamiliar with because I forgor U+1F480)
       #include "fuckmissingbracketsidontrememberwhatiwrotehere"
       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.