Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.lang.c Subject: Re: When do you use const Keywords: const, #define, C Message-ID: <578@taumet.com> Date: 4 Feb 91 16:24:12 GMT References: <1220@tredysvr.Tredydev.Unisys.COM> Organization: Taumetric Corporation, San Diego Lines: 13 paul@tredysvr.Tredydev.Unisys.COM (Paul Siu) writes: >However, what is the advantage of using const over #define? Why was the >reason for its addition to ANSI C. A lot of good answers were posted to this question, but I didn't see any mention of scoping. Macros are not scoped. They exist from the textual point of declaration to the end of the compilation, unless #undef'd. So an innocent #define buried somewhere in the program (inside a function, or in a nested include file) can unintentionally affect later code. -- Steve Clamage, TauMetric Corp, steve@taumet.com