Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!amdcad!light!bvs From: bvs@light.uucp (Bakul Shah) Newsgroups: comp.lang.c Subject: const pointers Message-ID: <1988Apr4.082020.1687@light.uucp> Date: 4 Apr 88 16:20:18 GMT References: <1988Apr3.013733.28401@utzoo.uucp> Reply-To: bvs@light.UUCP (Bakul Shah) Organization: Light Systems, Mountain View, CA Lines: 30 Summary: * const has a well defined and useful meaning In article <1988Apr3.013733.28401@utzoo.uucp> henry@utzoo.uucp (Henry Spencer) writes: > > ... const on a pointer does not mean that the >thing pointed to is constant, just that attempts to modify it through that ^^ >pointer are illegal. (If this double meaning of const strikes you as less >than ideal, you're in good company.) Huh? If by `it' you mean the object pointed to by the const pointer, your intepretation seems wrong (or I have misunderstood you or the draft). To manipulate an object at a fixed known location, we used to have to play games like #define ioreg ((long *)0x4000004) Instead, now we can say long * const ioreg = (long *)0x4000004; As I understand it, here `ioreg' is a const and `*ioreg' is a variable. In both cases *ioreg = 5; is legal, and ioreg = (long *)0x1234; is flagged by the compiler as illegal, which is exactly the effect one wants. I don't see a double meaning; perhaps you'd like to elaborate? -- Bakul Shah ..!{ucbvax,sun}!amdcad!light!bvs