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 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Tue, 04 Jul 2006 22:24:44 +0200 From: Gautier User-Agent: Thunderbird 1.5.0.4 (Windows/20060516) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Conditional compilation of debug traces without cpp References: <44aaae35$0$5389$626a54ce@news.free.fr> In-Reply-To: <44aaae35$0$5389$626a54ce@news.free.fr> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 83.79.149.59 X-Original-NNTP-Posting-Host: 83.79.149.59 Message-ID: <44aacee4$1_3@news.bluewin.ch> X-Trace: news.bluewin.ch 1152044772 83.79.149.59 (4 Jul 2006 22:26:12 +0200) Organization: Bluewin AG Complaints-To: abuse@bluewin.ch X-Original-NNTP-Posting-Host: 127.0.0.1 Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns14feed!worldnet.att.net!164.128.36.58!news.ip-plus.net!newsfeed.ip-plus.net!news.bluewin.ch!not-for-mail Xref: g2news2.google.com comp.lang.ada:5491 Date: 2006-07-04T22:24:44+02:00 List-Id: At least this works, with GNAT 3.15p and ObjectAda 7.2.2 SE: package Debug is procedure Put_Line (M : in String); pragma Inline(Put_Line); procedure Put_Line (M : in String; I: Integer); pragma Inline(Put_Line); end Debug; with Ada.Text_IO; package body Debug is Enabled : constant Boolean := False; procedure Put_Line (M : in String) is begin if Enabled then Ada.Text_IO.Put_Line (M); end if; end; procedure Put_Line (M : in String; I: Integer) is begin if Enabled then Ada.Text_IO.Put_Line (M & Integer'Image(I)); end if; end; end Debug; with Debug, Ada.Text_IO; procedure Test_debug is begin for I in 1..1234 loop Ada.Text_IO.Put_Line("[a]"); Debug.Put_Line ("(0) PC was here"); -- (0) Debug.Put_Line ("(1) PC was here, I = ", I); -- (1) Ada.Text_IO.Put_Line("[b]"); end loop; end; gcc -O2 -S -gnatpN test_debug.adb .file "test_debug.adb" gcc2_compiled.: ___gnu_compiled_ada: .text LC0: .ascii "[a]" .align 4 LC1: .long 1 .long 3 LC2: .ascii "(0) PC was here" _C7b.0: .ascii "(1) PC was here, I = " LC3: .ascii "[b]" .align 4 .globl __ada_test_debug __ada_test_debug: pushl %ebp movl %esp,%ebp pushl %ebx movl $1,%ebx .align 2,0x90 L37: movl $LC0,%eax movl $LC1,%edx pushl %edx pushl %eax call _ada__text_io__put_line$2 movl $LC3,%eax movl $LC1,%edx pushl %edx pushl %eax call _ada__text_io__put_line$2 addl $16,%esp incl %ebx cmpl $1234,%ebx jle L37 movl -4(%ebp),%ebx movl %ebp,%esp popl %ebp ret As you see, it does nothing else than writing the [a] and [b]. Similar thing for ObjectAda (Release mode). When you have concatenations and/or a function call in the parameter it doesn't work with these compilers - maybe, as you guess, they can't skip the computation of parameters. Or they may, or newer versions do. Perhaps it is a question of having a pragma Pure for the function. HTH, Gautier _______________________________________________________________ Ada programming -- http://www.mysunrise.ch/users/gdm/gsoft.htm NB: For a direct answer, e-mail address on the Web site!