fast code and no morals (C portability)
rex ballard
rb at ccivax.UUCP
Fri Feb 14 01:14:38 AEST 1986
In article <720 at ttrdc.UUCP> levy at ttrdc.UUCP (Daniel R. Levy) writes:
>
>What about a system where it is impossible to give command line arguments to a
>program, like the early-stone-age card reading IBM systems? Not all C runs
>on Unix ya know....
I have been using C on several machines and OS's, some so proprietary they
don't even have names. Much of the same code can be ported across several
of them.
>(Is C only allowed to run on machines that DO allow
>command line arguments?
No, but you may have to change the argument parser (main() in most cases)
to get the arguments from files, cards, tape, tty..., but this involves
changing only one routine, not the whole application.
Unix 'cheats'! There is a routine called 'start(), that sets up certain
internal arguments, file I/O buffers, assignments... calls main() (your
program) and then cleanup() which closes files, and cleans up memory...
Do the same with your 'stone age system, and the program may even run
unmodified.
>Would this program just get run with an argc of 0 in the case of a stone
>age system?
This largely depends on the compiler. One of our compilers would actually
allow only one argument from the OS, this was used as a pointer to a block
on disk where the arguments were stored.
>As a matter of fact, must a system support both upper and lower
>case characters to support C? (Would Cyber-type machines with 6 bit character
>codes be out of the running?)
One of our compilers only supported upper case characters, but code could
be written it and UNIX (for debug purposes) with almost no modification.
It was later replaced by a upper/lower case compiler and all properly
written code (linted), worked. V7 lint did not identify non-portable
character comparisons, but the latest 4.2 version does.
One can even write a 'stdio library' for RT-11 style file systems.
C has been available for CP/M for a while now, and works fairly well.
Not EVERYTHING written in C will work on EVERY machine UNMODIFIED, but
less modification will be required when porting between systems than
something written in assembler. This is especially important when the
target machine/OS does not have a strong debugger or support tools.
More information about the Comp.lang.c
mailing list