Visual Studio supports multiple compilers! Besides MSVC it is also possible
to use Clang, and supposedly GCC with Visual Studio 2019 [1]. This is good,
because it somewhat reduces the number of incompatible things that would
have to be fixed to compile Dispatch on Windows.
I just spent some time trying to compile on Windows 10 with Clang. I had to
change 22 files, usually small changes fixing header-file includes,
replacing POSIX constructs with either a no-op implementation (e.g. the
backtrace printing in alloc_pool.c) or with Windows-compatible
implementations that I was able to find on the internet (full-StackOverflow
development is a thing!). In total, I've touched 22 files and managed to
get it to compile, but not (yet) to link, since I sometimes just threw in
function declarations without implementations; I did that especially for
pthreads.
There are projects like PHP or PostgreSQL that implement various
multiplatform shims to support both POSIX and Windows in a single codebase.
That is possibly a great source of inspiration.
The largest area missing on Windows was pthreads, and the second largest
functions about system clock and time. All threading code is in
threading.c; time code is spread out more. There are reimplementations of
pthreads for Windows, I am sure something with a suitable licence can be
copy-pasted in. Licence is a problem. Dispatch may not vendor on any
GPL-licensed code.
Next up, there are likely going to be problems with making the tests work.
I did not get to trying that, so I don't know how hard that might be.
All in all, porting the C code for Windows looks quite doable, but it
pollutes the code with multiplatform constructs and indirection (including
platform-dependent versions of headers). I imagine having to care about
Windows would slow down POSIX development; the maintenance costs are
undeniable. Few well-placed macros could even make it work on MSVC, but
again, macros make things harder to work with.
Personally, I feel that supporting Windows does not pay off for the Qpid
Dispatch project as a whole. I haven't seen any user interest, except this
thread. The IOCP proactor in Proton might benefit though, since Dispatch
would exercise the Windows code. Compiling under Cygwin and maintaining
that ability is probably a better practical proposition anyways, if there
is inclination to support something on Windows. Or maybe just using Linux
for Dispatch. Azure will run Linux just fine. But all that is just my
personal opinion.
[1]
https://docs.microsoft.com/en-us/cpp/build/clang-support-msbuild?view=msvc-160