J
James Harris
James Kuyper said:The <stdint.h> header that was added in C99 provides three pairs of
families of type names: intN_t, int_leastN_t, and int_fastN_t.
Yes, I'm a little confused actually. <stdint.h> is the obvious choice,
and I'm wondering why OP isn't just using it.
His target systems include ones where C99 is not supported. Of course,
many of those systems support <stdint.h>, or some variant thereof, as a
C90 extension. Even on the ones that don't, it would be feasible to
provide your own, and there exist well-know versions in the public
domain. However, these points have been made to him, and don't seem to
have affected his thinking.
[OP] My thinking has been helped a lot by the recommendations people have
given. It's reasonble, though, not to feel obliged to do everything that
everyone advises.
To get 16-bit C compiles on Unix (which are not well supported) I have been
using bcc. It does not provide stdint.h.
I recently found a version of Open Watcom 16-bit compiler that would install
on Linux. That may provide a way to avoid some of the limitations of bcc.
The masochist in me, however, also thinks it could provide a good
alternative. Open Watcom will compile to large and compact models where bcc
only supports the tiny model. So I might just keep both. The differences
would be useful.
The fundamental problem, I think, is that he doesn't trust the C
compiler or <stdint.h> to have made what he considers to be the correct
choice. Using C necessarily involves giving up a certain amount of
control over the generated code, compared to assembly language. That's
part of what makes it a higher-level language. It's very low-level for a
high-level language, but it is still, definitely, a high-level language,
at least by comparison with assembler.
Not quite. I would normally trust stdint.h. I don't fully trust bcc and with
good reason. I found the other day that its realloc fails to copy the last
two bytes on some realloc calls. That's not a criticism of bcc per se. It is
free and known to be limited. But it illustrates why it's not always wise to
give carte blanche to a compiler.
I've seen such attitudes before, both in people moving to C from
assembler, and in C programmers who are temperamentally better suited to
being assembly language programmers than C programmers. The first group
needs to learn to let go and let C do its thing. The second group needs
to switch to some other language better suited to their temperaments.
There's possibly some truth in that character assessment. However, I also
choose to write a lot in Python which is much higher level than C. I'd like
to think I use the right tool for the job in hand.
For the piece of work I have in progress, low-level programming is needed.
It's as simple as that.
James