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,FREEMAIL_FROM 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!news3.google.com!news.glorb.com!wns14feed!worldnet.att.net!attbi_s02.POSTED!53ab2750!not-for-mail From: "Steve" Newsgroups: comp.lang.ada References: Subject: Re: Conditional compilation in Ada? X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Message-ID: NNTP-Posting-Host: 24.22.63.157 X-Complaints-To: abuse@comcast.net X-Trace: attbi_s02 1100659462 24.22.63.157 (Wed, 17 Nov 2004 02:44:22 GMT) NNTP-Posting-Date: Wed, 17 Nov 2004 02:44:22 GMT Organization: Comcast Online Date: Wed, 17 Nov 2004 02:44:42 GMT Xref: g2news1.google.com comp.lang.ada:6242 Date: 2004-11-17T02:44:42+00:00 List-Id: In general, the most effective way to make it easy to share code is to isolate the parts that are likely to change between uses, and provide different implementations for their uses. Without knowing more details, this sounds like a good place to use OOP. Instead of directly manipulating the data structure, use procedures to manipulate the data structure, and dispatch to the appropriate instance type for your target. IMHO conditional compilation is a bad thing. Especially if its use is not restricted. Steve (The Duck) "jtg" wrote in message news:cndgus$9g6$1@korweta.task.gda.pl... > 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? > 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?