Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!columbia!rutgers!clyde!cbosgd!ihnp4!occrsh!uokmax!rmtodd From: rmtodd@uokmax.UUCP (Richard Michael Todd) Newsgroups: comp.os.minix Subject: Re: More on sh/shar Message-ID: <581@uokmax.UUCP> Date: Sat, 30-May-87 22:01:49 EDT Article-I.D.: uokmax.581 Posted: Sat May 30 22:01:49 1987 Date-Received: Tue, 2-Jun-87 01:15:48 EDT References: <1643@encore.UUCP> Organization: University of Oklahoma, Norman, OK Lines: 33 Summary: UNIX and non-UNIX linkers handle global vars differently In article <1643@encore.UUCP>, paradis@encore.UUCP (Jim Paradis) writes: > Remember my last message complaining about /bin/sh being unable to > unpack "real" shell archives? Well, last night I got SO sick&tired > of the situation that I took a deep breath and dove head-first into > the code for /bin/sh. Getting it to compile was a feat unto itself... > (seems the MINIX compiler handles globals and externs differently > from the PC/IX compiler...). Yep. Actually it's a difference between how UNIX-type linkers (of which PC/IX's is apparently one) and most everybody else's handle globals. Under UNIX, you can have multiple files each with a global var. defined, say: file foo.c: int a; ... file bar.c: int a; ... and the UNIX linker will see the variable declared multiple times in the modules and allocate space in the result file only once. Most other linkers consider duplicate variable declarations to be errors. For C programs on those systems, the global definition can appear in only one file, and the other files must use extern declarations (e.g. "extern int a;"). On a side note, I've also gotten the shell to recompile, both under MINIX and under Aztec C (running the output thru dos2out). I changed all the offending definitions in sh.h (which gets included in every file) to read "EXTERN int whatever;" and #defined EXTERN extern in every file except one. Very minimal changes were needed to get it to compile under Aztec C after I'd gotten it to compile under MINIX cc. -------------------------------------------------------------------------- Richard Todd USSnail:820 Annie Court,Norman OK 73069 UUCP: {allegra!cbosgd|ihnp4}!okstate!uokmax!rmtodd