RE-flex icon indicating copy to clipboard operation
RE-flex copied to clipboard

Build issue on MSYS/UCRT64

Open cmburn opened this issue 6 months ago • 1 comments

Currently, the build fails on UCRT64 as there is no sys/select.h header. I patched it on my fork, but it was a quick fix and I'm not sure how you'd want that change integrated with the rest of RE-flex, particularly because it requires linking with ws2_32 now. I'm more than happy to open a pull request if you want.

cmburn avatar May 26 '25 16:05 cmburn

Thank you for your feedback. I will take a look at your fork. In the meantime, feel free to open a PR.

I'm not familiar with _UCRT and when it is used and by which compilers. Is it related to MinGW? A bit of Googling gives little information.

genivia-inc avatar Jun 16 '25 16:06 genivia-inc

UCRT is the Windows Universal C Runtime, which is what is being encouraged for windows development on MSYS now over regular MinGW. MinGW offers better compatibility with older windows systems, but doesn't support Windows XP or earler. It should, from my understanding, be applicable when building against the newer runtime.

I'll try and get a PR open later this week.

cmburn avatar Jun 17 '25 21:06 cmburn

I've made a change similar to yours for the upcoming release, but formatted differently, like so:

#if (defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(_WIN64) || defined(__BORLANDC__)) && !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__MINGW64__)
# include <io.h>
# include <fcntl.h>
# define off_t __int64
# define ftello _ftelli64
# define fseeko _fseeki64
#else
# include <unistd.h> // off_t, fstat()
# if (defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(_WIN64)) && (defined(__MINGW32__) || defined(__MINGW64__)) && defined(_UCRT)
#  include <winsock2.h>
# else
#  include <sys/select.h>
# endif
#endif

I believe this should work the same way. I've also updated CMakeLists.txt with the extra dependency:

if (MINGW AND WIN32)
    target_link_libraries(ReflexLib PRIVATE ws2_32)
    target_link_libraries(ReflexLibStatic PRIVATE ws2_32)
endif ()

genivia-inc avatar Jun 17 '25 23:06 genivia-inc

Fantastic; thank you!

cmburn avatar Jun 18 '25 00:06 cmburn