Kelsey Bjarnason wrote, On 13/09/07 00:47:
Kelsey said:
[snips]
On Wed, 12 Sep 2007 20:31:56 +1200, Ian Collins wrote:
If your code is processing a stream of say 16 bit data, you can either
assume the existence of a 16 (or 8) bit type
Like char and short? Oh, they're not required to be 8 and 16 bits, just
at least 8 and 16 bits. Meaning we've had perfectly good types for this
sort of thing since what, K&R?
So what would you rather have, code using short that compiles happily on
a system where short is 32 or 18 bits, but then fails to work (possibly
in a less than obvious way) or code that uses int16_t and won't compile?
I'd rather have code that compiles and works. Maybe that means masking,
fine, I can live with that if I have to.
Sometimes you would have to do a lot more than that, and you would be
doing it on a significant portion of the lines of code or doing a lot of
work to PROVE that you could get away without it.
Personally I prefer NOT to spend major effort on things which are
explicitly NOT a requirement.
At least I'd only have one code
path to maintain,
Those of us using uint16_t only have one code path because the code is
only required to work on platforms with a 16 bit unsigned integer type
without padding. We don't have to go through nests of conditional
compilation to mate it work.
Do you REALLY find so hard to understand that some code does not have to
be portable to every system? Will ALL of your code run on a system with
16 bit char, short and int with only 8K of space for the program and 8K
of space for data?
and it would work on _any_ conforming implementation.
So will ALL of your programs fit in to 8K of program space and 8K of
data space? I've spent a LOT of time programming for such systems,
although I don't now. However, back when I did the SW I wrote to process
live video definitely would NOT have fitted on such a small architecture
because it needed space for an entire frame of video, and it needed it
all in RAM for speed. Oh, and the processors on the small systems would
not be anywhere near fast enough. The code I currently work on requires
a few MB of program space, so also would not fit, and that is all code
REQUIRED to do the job.
NOW do you get that some code is not required to run on ANY conforming
implementations? Do you get that even YOU could not write code to solve
some problems that would run CORRECTLY on ANY conforming implementation?
We ALL accept restrictions in portability. It might be restricted to
only hosted implementations because it uses stdio. It might be
restricted to only implementations with more than the minimum of memory.
It might be restricted to only implementations with a networking (give
me a driver for a specific NIC that will work on a machine without ANY
NIC). Or it might be restricted to only implementations with a 16 bit
integer type with no risk of wanting it to run on a CRAY because you are
not going to get a CRAY installed in a fighter jet or a mobile phone.