comp.lang.ada
 help / color / mirror / Atom feed
From: Adrien Plisson <aplisson-news@stochastique.net>
Subject: Re: Conditional compilation in Ada?
Date: Wed, 17 Nov 2004 10:39:50 +0100
Date: 2004-11-17T10:39:50+01:00	[thread overview]
Message-ID: <419b1b9d$0$31945$ba620e4c@news.skynet.be> (raw)
In-Reply-To: <Wcsmd.94507$HA.85334@attbi_s01>

tmoran@acm.org wrote:

>   You can use an "if" statement.
> if Is_Version1 then ...
> else ...
>   If you define Is_Version1 at the top, or in another small package, as
>   Is_Version1 : constant Boolean := True;
> then an intelligent compiler will not generate any code for the impossible
> Is_Version1 = False condition or the if-test itself.  That is, it will be
> identical in effect to C conditional compilation.

will really the compiler not COMPILE the code impossible to reach ? i'm not 
that sure... it will generate no code, and maybe even no check at the entrance, 
but the code is still compiled and checked by the compiler for syntax errors, 
semantic errors and so on.

so, if he has a record:
type Version_1 is record
     Value_Version_1 : Any_Type;
end record

and another version:
type Version_2 is record
     Value_Version_2 : Any_Other_Type;
end record;

then code accessing the Version_1 record will not compile for Version_2, and 
vice versa. the "if" statement is then not an option, and is definitely not 
identical to the C conditional compilation. remember that the C preprocessor 
allows to do conditional COMPILATION, not conditional RUNTIME.

well, before everybody yell, i'm totally aware that this case is typically a 
bad design and should be rewritten using discriminated record. (but some people 
don't quite get it and still write this kind of code, especially in C with #if).

-- 
rien



  reply	other threads:[~2004-11-17  9:39 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 [this message]
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
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