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-Thread: 103376,634259facc42df7a,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!news3.google.com!news.glorb.com!newsgate.cistron.nl!xs4all!news2.euro.net!83.128.0.11.MISMATCH!news-out1.kabelfoon.nl!newsfeed.kabelfoon.nl!xindi.nntp.kabelfoon.nl!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!nntp.giganews.com!news.astraweb.com!newsrouter-eu.astraweb.com!proxad.net!cleanfeed2-a.proxad.net!nnrp2-2.free.fr!not-for-mail Date: Tue, 04 Jul 2006 20:06:51 +0200 From: guillaume.portail@grospied.enanglais.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr-FR; rv:1.7) Gecko/20040616 X-Accept-Language: fr, en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Conditional compilation of debug traces without cpp Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <44aaae35$0$5389$626a54ce@news.free.fr> Organization: Guest of ProXad - France NNTP-Posting-Date: 04 Jul 2006 20:06:46 MEST NNTP-Posting-Host: 82.228.125.157 X-Trace: 1152036406 nnrp2-2.free.fr 5389 82.228.125.157:33052 X-Complaints-To: abuse@proxad.net Xref: g2news2.google.com comp.lang.ada:5481 Date: 2006-07-04T20:06:46+02:00 List-Id: Hi, I have pieces of code like this (please just follow the general idea and forgive syntax errors) : package Debug is procedure Put_Line (M : in String); end; package body Debug is Enabled : constant Boolean := False; procedure Put_Line (M : in String) is begin if Enabled then Real_Put_Line (M); end; end; end; Many other units, many calls like : ... Debug.Put_Line ("PC was here, A = ", A_Type'Image(A)); -- (1) ... Debug.Enabled is a compile time constant, so with a bit of -O3 pragma Inline or other (-gnatN), the binary implementation of Debug.Put_Line will be null. But never will be the elaboration of the many calls to it. I guess that the elaboration of theses calls is always required by the language, think of : Debug.Put_Line ("PC was here, A = " & A_Function_Call(12)); -- (2) Debug.Put_Line ("PC was here, A = " & A_Function_Call(1/0)); -- (3) For my need, A_Function_Call is only for debugging purpose here, it has no side effect (it is a function). How may I organize the code to obtain the effect of having Debug.* calls being nulls when Debug.Enabled is False ? For your information, this is easy using cpp : #if _DEBUG #define DEBUG(x) real_put_line x #else #define DEBUG(x) 0 ... if (foo) { a = something; DEBUG(("PC was here, A=%d", b()+a)); } else DEBUG(("no foo")); ... And I would like not to use cpp or gnatprep, etc. What is the trick ? -- Thierry Bernier