The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
* [TUHS] Subject:   changes for modern -> v7 -> v6 -> v5
@ 2014-08-04  3:56 Doug McIlroy
  2014-08-04 19:11 ` scj
  0 siblings, 1 reply; 2+ messages in thread
From: Doug McIlroy @ 2014-08-04  3:56 UTC (permalink / raw)


> no conditional compilation so no way to make a truly universal version
> which works on everything.

If cc -I is there, it should be able to do the tailoring.

Also conditional compilation of non-declaration statements can
be replaced by regular if statements that typically can be
optimized away (though the old C compilers may not do so).


Incidentally, I would say that the use of conditional compilation
is evidence that the code is NOT truly universal, but has to be
specially adapted to various environments.

Doug



^ permalink raw reply	[flat|nested] 2+ messages in thread

* [TUHS] Subject:   changes for modern -> v7 -> v6 -> v5
  2014-08-04  3:56 [TUHS] Subject: changes for modern -> v7 -> v6 -> v5 Doug McIlroy
@ 2014-08-04 19:11 ` scj
  0 siblings, 0 replies; 2+ messages in thread
From: scj @ 2014-08-04 19:11 UTC (permalink / raw)



>
> Incidentally, I would say that the use of conditional compilation
> is evidence that the code is NOT truly universal, but has to be
> specially adapted to various environments.
>

For the most part, I agree, but there are some exceptions.  For example,
bit fields in C/C++ are laid out using the byte ordering conventions of
the target machine.  This can make it nearly impossible to write low-level
code to drive, e.g., hardware or communication protocols without
conditional compilation.

Of course, you can always shift and mask.  The code becomes
incomprehensible, but identical for big- and little-endian.  For my money,
using bit fields leads to code that is clear and easy to debug, and the
obvious rationale of the conditional code makes it a winner.

Steve




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-08-04 19:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-04  3:56 [TUHS] Subject: changes for modern -> v7 -> v6 -> v5 Doug McIlroy
2014-08-04 19:11 ` scj

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).