As usual with native code, portability is actually quite easy to achieve - except to Windows using MS's native tools.
As usual with native code, portability is actually quite easy to achieve - except to Windows using MS's native tools.
You can't just sort of tack portability on at the end, by targeting one system and then trying to build on the other one(s) right at the end. That's just going to involve a pile of work, that you could avoid. If you build on all of the systems you target, all the time, and fix problems as they arise, it's much easier.
There was (and maybe still is) this notion that portability for Windows programmers consisted of "Windows '95 AND Windows NT". There might be a newer version of the saying these days, probably "Windows 7 32-bit AND 64-bit". But anyway, it was rightly used as a stick to beat Windows programmers with. But the competing approach, of sticking to gcc, maybe using POSIX and pthreads, perhaps relying on fork a lot, etc., etc., and then crying foul when it won't work on Windows... well, that's always seemed to be perfectly acceptable for some reason ;)
The problem with POSIX, like any other standard, is that not all systems implement the same POSIX.
Additionally there are APIs which have undefined edge cases or different limits (e.g. amount of open file handles).
So even if you only target POSIX systems, you have to pollute the code with #ifdef to handle such differences.
It is similar to do web development. There are standards, but each browser version is a different world.
But it's certainly possible that Windows is even more bizarre than I suppose, in ways that I have yet to encounter.
It was interesting watching node/libuv face all the same problems I did when originally trying to abstract over this.
http://web.archive.org/web/20110719052845/http://developers....
Besides, the issue explicitly brought up was the fact the Microsoft C++ compiler does not fully support C-11.
As for your other point, it's indeed true that some systems are more like some other systems, and not like others. But so what? If you want your code to be portable, it needs to build on all the targets you support. So you need to do that. Perhaps people assume there's some magic bullet, or secret special thing that you can do? Sadly not, just the usual - work and some forward planning.
I always hear statements like this from people that never did real cross platform development.
There are more operating systems in the world than just plain POSIX and Windows.
Even POSIX if one constrains to POSIX compliant systems, is a bag full of surprises due to undefined behaviours in the standard.
This is cross-platform coding 101...