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,c35edbbda4c7f58f X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!proxad.net!proxad.net!skynet.be!newspost001!tjb!not-for-mail Date: Wed, 17 Nov 2004 10:39:50 +0100 From: Adrien Plisson User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) X-Accept-Language: fr-fr, fr-be, fr, en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Conditional compilation in Ada? References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <419b1b9d$0$31945$ba620e4c@news.skynet.be> Organization: -= Belgacom Usenet Service =- NNTP-Posting-Host: f2425db2.news.skynet.be X-Trace: 1100684189 news.skynet.be 31945 80.200.29.54:3102 X-Complaints-To: usenet-abuse@skynet.be Xref: g2news1.google.com comp.lang.ada:6244 Date: 2004-11-17T10:39:50+01:00 List-Id: 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