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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,196864e6c216ca4f X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-09-29 11:12:01 PST Path: news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread3.news.pas.earthlink.net.POSTED!not-for-mail From: Jeffrey Carter Organization: jrcarter commercial-at acm [period | full stop] org User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: How to Emulate C++ Macro with Static Local Variable? References: <3F73107A.1060502@attbi.com> <04Hcb.577973$Ho3.106182@sccrnsc03> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Mon, 29 Sep 2003 18:12:00 GMT NNTP-Posting-Host: 63.184.1.122 X-Complaints-To: abuse@earthlink.net X-Trace: newsread3.news.pas.earthlink.net 1064859120 63.184.1.122 (Mon, 29 Sep 2003 11:12:00 PDT) NNTP-Posting-Date: Mon, 29 Sep 2003 11:12:00 PDT Xref: news1.google.com comp.lang.ada:189 Date: 2003-09-29T18:12:00+00:00 List-Id: taashlo@sandia.gov wrote: > tmoran@acm.org writes: > >> void log(int *t){if(*t++ > 100)raise_the_exception;} >> #define LOG if (1) { \ >> static int t_; \ >> log(&t_);\ >> } else ((void)0) Are ints in C++ automatically initialized to zero? I admit my C++ is not very good, but this looks as if it could raise the exception after fewer than 100 invokations, or after 101 invocations. (I assume this is C++ and not C because I don't recall C having exceptions.) > There's only two options that I can think of: > > 1) Use a unique ID for each call. But this turns into a maintenance > nightmare when you get a few hundred calls or more. > > 2) Use the return address of the call. But there was a short discussion > about how Ada doesn't currently have a way of accessing the return > address of a subprogram. 3. Use a unique instantiation of a generic package for each call. The instantiations of the package must be at a nesting level that ensures that they will exist for the entire lifetime of the executable region in which they are used. -- Jeff Carter "You tiny-brained wipers of other people's bottoms!" Monty Python & the Holy Grail 18