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,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!t20g2000yqa.googlegroups.com!not-for-mail From: Warren Newsgroups: comp.lang.ada Subject: Ada Smileys in C++ lib Conversion Date: Fri, 13 Aug 2010 07:20:16 -0700 (PDT) Organization: http://groups.google.com Message-ID: <1a9b39b0-73f6-497c-a8f4-abf8129886ac@t20g2000yqa.googlegroups.com> NNTP-Posting-Host: 216.121.235.102 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1281709216 5188 127.0.0.1 (13 Aug 2010 14:20:16 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 13 Aug 2010 14:20:16 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: t20g2000yqa.googlegroups.com; posting-host=216.121.235.102; posting-account=ENgozAkAAACH-stq5yXctoDQeZQP2E6J User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 ( .NET CLR 3.5.30729),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:13219 Date: 2010-08-13T07:20:16-07:00 List-Id: This week I've been busy porting last year's C++ version of my midi library over to Ada (now that I'm using AVR-Ada). As part of that effort, the Ada compiler has discovered a few errors that were lurking still in the C++ Arduino code. In C++ I had defined: /* * MC_CTL_CHG Control values : */ #define MC_CTL_ALLS_OFF 0x78 // All sounds off (120) #define MC_CTL_RESET_C 0x79 // Reset controller #define MC_CTL_LOCAL_C 0x80 // Local on/off #define MC_CTL_ALLN_OFF 0x81 // All notes off #define MC_CTL_OMNI_OFF 0x82 // Omni off request #define MC_CTL_OMNI_ON 0x83 // Omni on request #define MC_CTL_MONO_ON 0x84 // Mono on == POLY OFF #define MC_CTL_MONO_OFF 0x85 // Mono off == POLY ON But in Ada, when I declared: type Control_Type is new Unsigned_8 range 0..127; and then coded: case Control is when MC_CTL_ALLS_OFF => -- ok ... when MC_CTL_LOCAL_C => -- oops ... 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: #define MC_CTL_ALLS_OFF 0x78 // All sounds off (120) #define MC_CTL_RESET_C 0x79 // Reset controller #define MC_CTL_LOCAL_C 0x7A <==== not 0x80 #define MC_CTL_ALLN_OFF 0x7B <==== not 0x81.. Non commands in midi should not have had bit 7 set. So as it was coded, those control messages would never have been processed in the C++ lib. I'm always smiling when I convert code from C/C++ to Ada. In code of any significant size, Ada always discovers problems that went unnoticed in C/C++. Warren