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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM 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!postnews.google.com!i31g2000yqm.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: Ada Smileys in C++ lib Conversion Date: Mon, 16 Aug 2010 05:39:34 -0700 (PDT) Organization: http://groups.google.com Message-ID: <4915efdd-46ba-436b-b989-6067ce5a03bf@i31g2000yqm.googlegroups.com> References: <1a9b39b0-73f6-497c-a8f4-abf8129886ac@t20g2000yqa.googlegroups.com> <9b88e5a4-c588-4997-ad5c-2efa216fe4f4@a4g2000prm.googlegroups.com> <95tc66hjv3stdk0nhdv9o46e5l2ecdog5j@4ax.com> <15cdcb9e-3747-48e3-9be0-8829dfbcc3c8@w30g2000yqw.googlegroups.com> NNTP-Posting-Host: 137.138.182.236 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1281962377 17482 127.0.0.1 (16 Aug 2010 12:39:37 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 16 Aug 2010 12:39:37 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: i31g2000yqm.googlegroups.com; posting-host=137.138.182.236; posting-account=bMuEOQoAAACUUr_ghL3RBIi5neBZ5w_S User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6,gzip(gfe) Xref: g2news1.google.com comp.lang.ada:13405 Date: 2010-08-16T05:39:34-07:00 List-Id: On 16 Sie, 14:30, Brian Drummond wrote: > The real case was a bit stranger than previous reply (simplifying to a 1-= D > array) > > const int xdim =3D 7; =A0 =A0 > const int size =3D xdim; =A0// was a function of all dimensions > int array[size]; > ... > error: initializer element is not constant > error: variably modifed 'array' at file scope > > So a "const" is not constant, says the compiler. The above is guaranteed to work by the C++ standard (nerds see 5.19/1). The problem will be when the initializer for "size" above will indeed be a function call - this would not be a constant expression, even though the object "size" is declared as const. The reason is that constant expression should always evaluate to the same value, whereas function calls are not required (and cannot be verified) to do so. So, there is a difference between a "constant expression" (roughly equivalent to Ada's "static expression") and a "const object". Array bounds require constant expression. -- Maciej Sobczak * http://www.inspirel.com YAMI4 - Messaging Solution for Distributed Systems http://www.inspirel.com/yami4