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,703c4f68db81387d X-Google-Thread: 109fba,703c4f68db81387d X-Google-Thread: 115aec,703c4f68db81387d X-Google-Thread: f43e6,703c4f68db81387d X-Google-Attributes: gid103376,gid109fba,gid115aec,gidf43e6,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.glorb.com!news-feed01.roc.ny.frontiernet.net!nntp.frontiernet.net!newscon06.news.prodigy.com!prodigy.net!newsfeed-00.mathworks.com!panix!panix1.panix.com!not-for-mail From: comeau@panix.com (Greg Comeau) Newsgroups: comp.lang.ada,comp.lang.c++,comp.realtime,comp.software-eng Subject: Re: [OT] Re: Teaching new tricks to an old dog (C++ -->Ada) Date: 12 Mar 2005 22:21:19 -0500 Organization: Comeau Computing; http://www.comeaucomputing.com Message-ID: References: <4229bad9$0$1019$afc38c87@news.optusnet.com.au> <1110607809.837000@at <1110655701.196383@athnrd02> Reply-To: comeau@comeaucomputing.com NNTP-Posting-Host: panix1.panix.com X-Trace: reader1.panix.com 1110684080 8058 166.84.1.1 (13 Mar 2005 03:21:20 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Sun, 13 Mar 2005 03:21:20 +0000 (UTC) Xref: g2news1.google.com comp.lang.ada:9285 comp.lang.c++:45383 comp.realtime:1404 comp.software-eng:4970 Date: 2005-03-12T22:21:19-05:00 List-Id: In article <1110655701.196383@athnrd02>, Ioannis Vranos wrote: >Martin Krischik wrote: > >> Well actualy: since 4 is not a valid value for the enum four_val the Ada >> compiler won't compile the code - Ada does not automaticy convert enums >> into integer. >> >> The way you would do it in Ada is >> >> pragma Assert (x'Valid); >> >> The 'Valid attribute checks if a variable contains a valid value. > > >Now that I am thinking of it, isn't it a value range? > > >int main() >{ > enum four_val {a,b,c,d}; > > four_val x; > > x = 4; >} > > >C:\c>g++ temp.cpp -o temp.exe >temp.cpp: In function `int main()': >temp.cpp:7: error: invalid conversion from `int' to `main()::four_val' In C++ but not in C it's an error, but it can also be "invalidly" cast to the enum. -- Greg Comeau / Comeau for the Mac? Stay tuned. Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90. Comeau C/C++ with Dinkumware's Libraries... Have you tried it?