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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!newsfeed.stueberl.de!newsfeed01.sul.t-online.de!newsmm00.sul.t-online.de!t-online.de!news.t-online.com!not-for-mail From: Martin Krischik Newsgroups: comp.lang.ada Subject: Re: Conditional compilation in Ada? Date: Wed, 17 Nov 2004 10:28:24 +0100 Organization: None Message-ID: <1493083.5zr6NCs8u0@linux1.krischik.com> References: Reply-To: martin@krischik.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: news.t-online.com 1100684110 03 28596 +Wc0X+brhcvsStRV 041117 09:35:10 X-Complaints-To: usenet-abuse@t-online.de X-ID: Jre7E8ZJwebhG8zKP1qUtge9ncu4YP2hHPiVembx9VmlXQAxFyRYc2 User-Agent: KNode/0.8.0 Xref: g2news1.google.com comp.lang.ada:6245 Date: 2004-11-17T10:28:24+01:00 List-Id: jtg wrote: > I am using Ada for many years now, but recently > I stumbled upon a problem I cannot solve: I need > some kind of conditional preprocessing, which is > commonly used in C programs: > > #ifdef CONDITION > (some source code) > #else > (other source code) > #endif > > How to achieve it with Ada? Depends on the Ada compiler you use. GNAT has "GNAT PREPROCESS" or "gnatprep" for short. You need to RTFM ;-) on how to use "GNAT PREPROCESS". > I am developing two applications which are very similar > and share the same source code. The only difference is > a small change in a fundamental data structure. Both versions of the > data structure are mostly handled the same way (within thousands of > lines of source code), but there are some 10 or 20 (number still > growing) places where minor changes are necessary. What is worse, > during the development every several hours I have to prepare > and run both the applications. To do this, I have to perform > "human preprocessing": find those places, comment lines > for app1, and uncomment lines for app2. This is very error prone and > I have already made a mistake. > > Any hints? Well in AdaCL long ago I used "GNAT PREPROCESS" - however once I learned the Ada way more closely I removed all use "GNAT PREPROCESS" and used the build management instead: All differences where encapsulated in private "XXX.Low_Level" packages. When suitalble "pagama Inline" was uesd. Those packages where moved ito "NT", "Linux" and "OS2" directories. The build mamagement picks up the version needed. With Regards Martin -- mailto://krischik@users.sourceforge.net http://www.ada.krischik.com