Eric said:
Sure, I'll tell them their [platform-specific] headers are not portable.
I'll say the same about the platform's <setjmp.h>, <stdint.h>, and
<float.h>: All are non-portable, in the sense that the file that
works with one implementation need not work with the next.
So you would avoid setjump because it isn't portable? Obviously not. If
at platform provides the means to use a feature, use it. This case may
be constrained to those platforms which support networking, but you
wouldn't be manipulating IP packets anywhere else, would you?
The point you're missing is that one platform's headers are not
portable to another platform, even if the interfaces they describe
are. The bit-fields in the headers' structs (if they use them) are
specific to the platform for which they were written, and will not
necessarily work on other platforms, not even on *any* other platform.
Offering bit-fields as a portable means to achieve an externally-
defined format is folly: It may be possible to match the format on
Platform P with Declaration D, but Declaration D could yield an
entirely different format when compiled on Platform Q.
The lack of any definition
of "common sense" leaves enough wiggle room for a septillion
slippery slimy eels. Even so, "I've never seen it, ergo it
merits no consideration" is an argument unworthy of debate.[*]
If there is more than one compiler for a given platform, they are very
unlikely to order bit-fields differently. Yes I haven't seen them all,
but I have seen a lot over the past 30 years or so. If you know of a
counterexample, I'm interested.
Portability between multiple compilers for a single platform
is occasionally of interest, typically when you're compiling your
own source with Compiler A but using somebody else's binary library
built with Compiler B. Such situations are far from unknown -- I've
dealt with them often enough. (I recall once finding a SIGSEGV in
a binary-only library whose supplier was not interested in fixing it,
and using hex-mode Emacs to turn it into a slow memory leak instead.
Not ideal, but better to let the balloon hiss slowly than go POP!)
However, when people speak of "portability" it seems to me they
are more usually concerned with portability between different systems,
possibly running on different hardware. Development being expensive,
one wants to produce code that can move with minimal effort from
Windows to Linux to Solaris to OS/400, from x86 to x64 to ARM to
Itanium to SPARC to PowerPC to ... If you want to match a dictated
format on all these platforms and more, you should avoid bit-fields;
in fact, you should avoid structs altogether for this purpose.