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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,a6fe9ef21ba269dc X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news2.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.bt.com!news.bt.com.POSTED!not-for-mail NNTP-Posting-Date: Sat, 14 Aug 2010 05:49:41 -0500 From: Brian Drummond Newsgroups: comp.lang.ada Subject: Re: Ada Smileys in C++ lib Conversion Date: Sat, 14 Aug 2010 11:57:07 +0100 Reply-To: brian@shapes.demon.co.uk Message-ID: <95tc66hjv3stdk0nhdv9o46e5l2ecdog5j@4ax.com> References: <1a9b39b0-73f6-497c-a8f4-abf8129886ac@t20g2000yqa.googlegroups.com> <9b88e5a4-c588-4997-ad5c-2efa216fe4f4@a4g2000prm.googlegroups.com> X-Newsreader: Forte Agent 1.7/32.534 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Usenet-Provider: http://www.giganews.com X-AuthenticatedUsername: NoAuthUser X-Trace: sv3-u4PCtxtQTd1sSpR5rZMGP+B1ejHmO7cwvUxSMHIbRhi8NiMq7LLewoGH9WlIev8WIipgu6fKp3zBk68!0ljTdng5w82TRQHamqOAeZv5nIVzXRQgipNlDcVdWhzaG+hiAot+vV46GUJ9DttBxhM2pML5SWTh!b3o= X-Complaints-To: abuse@btinternet.com X-DMCA-Complaints-To: abuse@btinternet.com X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 Xref: g2news1.google.com comp.lang.ada:13274 Date: 2010-08-14T11:57:07+01:00 List-Id: On Fri, 13 Aug 2010 18:36:38 -0700 (PDT), Warren wrote: >On Aug 13, 12:53�pm, Anh Vo wrote: >> On Aug 13, 7:20�am, Warren wrote: #define MC_CTL_LOCAL_C 0x80 // Local on/off #define MC_CTL_ALLN_OFF 0x81 // All notes off >> > it immediately identified the value MC_CTL_LOCAL_C >> > (and others) as not fitting into the Control_Type's >> > valid range. In C++ a glaring error had gone >> > unnoticed: >> I am smiling, too, since I am not surprised at all. >Heh heh. This is one of those things that C/C++ cannot >guard against at all. Unless the value(s) were to exceed >the underlying type's storage capability, the compiler >is helpless to identify it. There is simply no concept of >a "range" of valid values in that language. > >About the only thing you could do (in C/C++) is to code >a macro check on the constants, but I don't think I've >ever seen it done in practice. Only as a argument value >assertion check in strategic places. Heh too. I thought I was being really really smart years ago in C, when I decided to convert all those #defines to integer constants... const int MC_CTL_LOCAL_C = 0x80; and so on. Of course I was declaring integer variables, who's storage class happens to be named "constant". But it certainly puzzled me to be told that I couldn't use a "const" in a constant expression! - Brian