comp.lang.ada
 help / color / mirror / Atom feed
From: Arthur Schwarz <aschwarz@acm.org>
Subject: Re: Conditional compilation in Ada?
Date: Mon, 22 Nov 2004 17:15:41 -0800
Date: 2004-11-22T17:15:41-08:00	[thread overview]
Message-ID: <41A28F3D.2030008@acm.org> (raw)
In-Reply-To: <pan.2004.11.20.01.05.29.885101@linuxchip.demon.co.uk.uk.uk>

Dr. Adrian Wrigley wrote:
>>pragma Ignore ( -- compiler warning 
>> DEBUG.put_line
>> (  "Here " & Is.Something ("reasonable complex to evaluate")
>> )
>>);
> 
> 
> Maybe I'm being stupid, but how does this help?
> Doesn't this always have no effect?
> 
> I'd like to switch debugging on/off without editing every
> DEBUG statement in the source...

Same problem. What I usually do is use a flexible scheme to represent 
debug flags. If I want the code permanantly removed, I set the debug 
flags to:

     Debug_Flag : constant Boolean := FALSE;

and if I want the conde permanently available, I set the debug flags to:

     Debug_Flag : constant Boolean := TRUE;

and if I want to (interactive) change my mind, I set the debug flags to:

     Debug_Flag : Boolean := TRUE;

The pragma inline (below) conserves code and enables identification of 
debug sections - it is for a maintainer's notification and does nothing 
in terms of code or code integrity. And I know, I know, 'pragma inline' 
is only a suggestion to the compiler - but a good one.

The Is_Debug functions are tailored to suit. I've given only a clear (?) 
and simple presentation of principle.

Forgive the Ada.

Hope this provides a focus for conversation. It would be nice to see 
what debug things are out their.

art


Package one body is

Debug_Flag  : Boolean := TRUE;  // Note: this is a variable
                                 // and placed in the spec file.

function Is_Debug return Boolean is
begin -- Is_Debug
    return Debug_Flag;
end Is_Debug;
pragma inline( Is_Debug );


end one;

Package two body is

Debug_Flag  : Boolean := TRUE; // same as above

function Is_Debug return boolean is
begin -- Is_Debug
    return Debug_Flag and one.Is_Debug;
end Is_Debug;


procedure Some_Thing is
begin -- Some_Thing
    if ( Is_Debug ) then
      null;
    end if;
end Some_Thing;
end two;




  parent reply	other threads:[~2004-11-23  1:15 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-16 18:30 Conditional compilation in Ada? jtg
2004-11-16 18:45 ` Marius Amado Alves
2004-11-16 20:41   ` Nick Roberts
2004-11-17  8:36     ` Alex R. Mosteo
2004-11-16 19:03 ` Jeffrey Carter
2004-11-16 19:13   ` Hyman Rosen
2004-11-16 19:41     ` Björn Lundin
2004-11-16 20:08     ` tmoran
2004-11-16 20:27       ` Hyman Rosen
2004-11-16 23:49         ` Jim Rogers
2004-11-16 20:43     ` Martin Dowie
2004-11-16 19:06 ` tmoran
2004-11-17  9:39   ` Adrien Plisson
2004-11-17 16:39     ` Jacob Sparre Andersen
2004-11-17  2:44 ` Steve
2004-11-17 20:30   ` Jeffrey Carter
2004-11-18  4:09     ` Steve
2004-11-18  6:49       ` Martin Dowie
2004-11-18 15:17         ` Georg Bauhaus
2004-11-18 19:12           ` Martin Dowie
2004-11-18 17:34         ` Jeffrey Carter
2004-11-18 17:44       ` Jeffrey Carter
2004-11-18 18:03         ` Alex R. Mosteo
2004-11-19  3:00           ` Steve
2004-11-19 21:35             ` Simon Wright
2004-11-20  2:56               ` Steve
2004-11-20 16:57                 ` Simon Wright
2004-11-17  9:28 ` Martin Krischik
2004-11-17 13:39   ` Stephen Leake
2004-11-17 10:02 ` Frank Piron
2004-11-17 12:32   ` Georg Bauhaus
2004-11-17 14:44     ` Dmitry A. Kazakov
2004-11-18 15:23       ` Georg Bauhaus
2004-11-18 22:10         ` Brian May
2004-11-19  9:03           ` Martin Krischik
2004-11-20 17:31             ` Georg Bauhaus
2004-11-21  9:14               ` Martin Krischik
2004-12-12  0:36               ` Lionel Draghi
2004-12-12  0:17             ` How to switch off those damm warnings about unknows pragma Lionel Draghi
2004-12-13 11:10               ` Georg Bauhaus
2004-12-13 15:07               ` Peter Amey
2004-11-20  1:05         ` Conditional compilation in Ada? Dr. Adrian Wrigley
2004-11-20 17:25           ` Georg Bauhaus
2004-11-23  1:15           ` Arthur Schwarz [this message]
2004-11-23 15:42             ` skidmarks
2004-11-17 12:27 ` Marin David Condic
  -- strict thread matches above, loose matches on Subject: below --
2004-11-19  9:13 Christoph Karl Walter Grein
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox