Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!rochester!ritcv!ccivax!rb From: rb@ccivax.UUCP (rex ballard) Newsgroups: net.lang.c Subject: Re: fast code and no morals (C portability) Message-ID: <400@ccivax.UUCP> Date: Thu, 13-Feb-86 10:14:38 EST Article-I.D.: ccivax.400 Posted: Thu Feb 13 10:14:38 1986 Date-Received: Sun, 16-Feb-86 04:27:52 EST References: <842@megaron.UUCP> <1820@brl-tgr.ARPA> Reply-To: rb@ccivax.UUCP (What's in a name ?) Distribution: net Organization: CCI Telephony Systems Group, Rochester NY Lines: 47 In article <720@ttrdc.UUCP> levy@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.