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.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6e064806c6a78fe4 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-04-12 22:37:51 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!out.nntp.be!propagator2-sterling!news-in.nuthinbutnews.com!cyclone1.gnilink.net!spamkiller2.gnilink.net!nwrdny01.gnilink.net.POSTED!53ab2750!not-for-mail From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4a) Gecko/20030329 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Ada to C Question References: <2a159604.0304120643.39f77838@posting.google.com> <20_la.432304$F1.63444@sccrnsc04> <2a159604.0304121850.2820b67f@posting.google.com> In-Reply-To: <2a159604.0304121850.2820b67f@posting.google.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Sun, 13 Apr 2003 05:37:50 GMT NNTP-Posting-Host: 162.83.250.200 X-Complaints-To: abuse@verizon.net X-Trace: nwrdny01.gnilink.net 1050212270 162.83.250.200 (Sun, 13 Apr 2003 01:37:50 EDT) NNTP-Posting-Date: Sun, 13 Apr 2003 01:37:50 EDT Xref: archiver1.google.com comp.lang.ada:36110 Date: 2003-04-13T05:37:50+00:00 List-Id: MPowell wrote: > Of course in C (porting to C) declarations above don't work. As far > as the typedef sees 'it' some parameters are just re-declarations. The right way to do these in C++ is as follows: struct SET_RESET_TYPE { enum { Set, Reset } e; }; struct RESET_SET_TYPE { enum { Reset, Set } e; }; // etc. and qualify the literals with the appropriate type, eg., SET_RESET_TYPE::Set > I'm not sure how I could handle 'generics' in C. So now: > > generic > type ELEMENT is private; > Initial_Element : ELEMENT; > > package Protected_Msg is > function Read return ELEMENT; > procedure Push (E : Element); > end Protected_Msg; > > the package body follows. Again, use C++. Things may vary depending on how Initial_Element is used. template struct Protected_Msg { static ELEMENT Read(); static void Push(ELEMENT); static ELEMENT Initial_Element(); }; > type TEMPERATURE is Float; > subtype TEMP_RANGE is TEMPERATURE range -50 .. 50; > > I like subtypes in Ada but no way to handle subtypes in C so I have to > use #define max and min and use if statments. Again, using C++ you could define a class which would do the range checks.