Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!udel!haven!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: Novice question. Message-ID: <14458@smoke.brl.mil> Date: 14 Nov 90 15:40:26 GMT References: <1990Oct31.014132.2400@agate.berkeley.edu> <336@brat.UUCP> <3838@vela.acs.oakland.edu> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 21 In article <3838@vela.acs.oakland.edu> jmwojtal@vela.acs.oakland.edu (Wojo) writes: >What exactly are the reasons "register" and "extrn" are used to declare >values. I see register alot in some of the programs and I don't know why >they do it. Is it just good practice or what. "extern" is important in that it makes a declaration a reference to something defined elsewhere; objects declared without extern at "file scope" (outside of any function) constitute definitions, and there may be but one definition per object among ALL the "translation units" (source files, or corresponding object modules) constituting a complete program. "register" is just an efficiency hint to the compiler, requesting that the object be assigned to "fast" storage such as a machine register. Many modern compilers just ignore explicit "register" requests and allocate storage as they deem fit. My suggestion is to not use "register" except when you've already tried everything else to speed up the code and still need a smidgen more speed. Undoubtedly these are explained in Kernighan & Ritchie's "The C Programming Language" (either edition).