Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: Does extern "const" allocate storage? Message-ID: <7485@brl-smoke.ARPA> Date: 20 Mar 88 02:49:03 GMT References: <7712@apple.Apple.Com> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 33 In article <7712@apple.Apple.Com> lenoil@apple.UUCP (Robert Lenoil) writes: >const int foo = 3; In general, "const" in ANSI C does not mean the same as in Pascal etc. (C's equivalent to that is "manifest constant" preprocessor macros.) Unless the compiler can ascertain that it is impossible for any code to need the variable `foo' to really exist, it is obliged to generate storage for `foo'. Think of "const" as "readonly" and you'll have a good idea of its intended properties. >... can someone translate their definition of noalias into English for me? There are definitely some problems with the current specification of type qualifiers, which will probably be fixed one way or another at the April X3J11 meeting. (The possibilities range from minor tweaks to the current specs to fix technical errors, through removing "noalias" altogether and possibly adding some other support for certain types of optimization, such as Peter Darnell's [] proposal.) Basically, "noalias" is a hint that, although as usual in C there can be multiple "handles", i.e. access paths to an object's content, the first noalias "handle" used is the master version, which is guaranteed to always reference the official object content, and access via other handles need not always go fetch the current object content for safety (as is required if "noalias" is not used), but instead can use cached copies of the object. The only purpose of all this is to allow just that sort of caching, which is a form of optimization that some people consider important. For example, it allows vectorizing machines to employ vector operations where normally C would say that they could not be safely used. I think I got that substantially right, although I may have messed up a few details. Hey, I don't plan to use this stuff!