Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!know!sdd.hp.com!elroy.jpl.nasa.gov!ncar!midway!iitmax!gkt From: gkt@iitmax.IIT.EDU (George Thiruvathukal) Newsgroups: comp.lang.c Subject: Re: Novice question. Message-ID: <4524@iitmax.IIT.EDU> Date: 15 Nov 90 05:45:09 GMT References: <1990Oct31.014132.2400@agate.berkeley.edu> <336@brat.UUCP> <14624@neptune.inf.ethz.ch> Organization: Illinois Institute of Technology, Chicago Lines: 28 In article <14624@neptune.inf.ethz.ch>, mneerach@iiic.ethz.ch (Matthias Ulrich Neeracher) writes: > "extern" essentially tells the compiler that this variable is defined > elsewhere. It is truly unfortunate the "extern" keyword exists in C. Let us examine the following code fragment which allocates a vector of a size which is unknown until function xyzpdq is encoded. extern int TempCount; void xyzpdq() { void **temporaries = (void **)calloc(TempCount,sizeof(void *)); /* code */ free(temporaries); } /* resolution of TempCount in same compilation unit */ int TempCount = 5; Although one might not opt to allocate temporary variables in exactly the above fashion, it is easier than backpatching the code. It manifests a usage of extern within the same compilation unit as the external reference. George Thiruvathukal gkt@iitmax.iit.edu