From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a1a88c4d509f6381 X-Google-Attributes: gid103376,public From: Hyman Rosen Subject: Re: scope and/or parameters (beginner) Date: 1999/04/15 Message-ID: <371627B2.BA3E914C@prolifics.com>#1/1 X-Deja-AN: 466799448 Content-Transfer-Encoding: 7bit References: <37064309.889106243@news.dsuper.net> <37084459.8616007@rocketmail.com> <370b0c99.1137352783@news.dsuper.net> <7f2435$54d$1@nnrp1.dejanews.com> <37149AE9.883147B6@prolifics.com> <7f2ar3$b6l$1@nnrp1.dejanews.com> <3714EEC5.689CCFBB@prolifics.com> <7f2vdl$uf6$1@nnrp1.dejanews.com> <37151A6D.FAA4ACA2@prolifics.com> <7f4sh1$h8l$1@nnrp1.dejanews.com> <7f51r8$m5r$1@nnrp1.dejanews.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@panix.com X-Trace: news.panix.com 924198756 1653 209.49.126.226 (15 Apr 1999 17:52:36 GMT) Organization: Prolifics Mime-Version: 1.0 NNTP-Posting-Date: 15 Apr 1999 17:52:36 GMT Newsgroups: comp.lang.ada Date: 1999-04-15T17:52:36+00:00 List-Id: Robert Dewar wrote: > You also have to consider the knowledge base, i.e. do > programmers know all the relatively new stuff in the ANSI > C standard, and can they count on maintenance programmers > to know it. > > When it comes to const, this is of course an important > feature, but it does not BEGIN to have become standard > practice in C code, and indeed virtually all API's I > have worked with seem to prefer to use #define in the > traditional manner to using const. This is not a decision > I approve of, I am merely making an observation, it takes > time for things to change. I don't think that the dearth of const in C code is because of lack of knowledge. The problem with const is that it is infectious where it is most needed, with respect to pointers. Once an object is const, pointers to that object can not be passed as parameters to routines which expect non-const pointers (unless casts are used). Unfortunately, many APIs predate const, and so use non-const pointers even when they do not modify the pointed-to data. As far as const-vs.-#define, you cannot use const objects as parts of constant expressions in C. (You can in C++.) The best way to declare integer constants in C is through enum.