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!news1.google.com!fu-berlin.de!uni-berlin.de!not-for-mail From: "Nick Roberts" Newsgroups: comp.lang.ada Subject: Re: Conditional compilation in Ada? Date: Tue, 16 Nov 2004 20:41:18 -0000 Message-ID: <2vv6vfF2q17krU1@uni-berlin.de> References: X-Trace: news.uni-berlin.de SonmkFminoiytTOLemvPhQF7PhL2poMvhiERA6qPsUhXO4TBs= X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-RFC2646: Format=Flowed; Response Xref: g2news1.google.com comp.lang.ada:6235 Date: 2004-11-16T20:41:18+00:00 List-Id: "Marius Amado Alves" wrote in message news:mailman.103.1100630792.10401.comp.lang.ada@ada-france.org... >> Any hints? > > Gnatprep. In a little more detail, declare the things that differ (types, associated operations) in two separate packages, say Stuff_For_Playstation and Stuff_For_XBox, then put something like this: Compile_Target := XBox into a text file called "targspec.txt" (say), and then something like this in the appropriate places in your source files: with Stuff_For_$Compile_Target; ... package Target_Specific renames Stuff_For_$Compile_Target; ... Target_Specific.Reset_Joystick; -- or whatever and rename every so doctored source file myfile.ads to myfile.adsp (and myfile.adb to myfile.adbp) and then run: gnatprep myfile.adsp myfile.ads targspec.txt -c -r for each such source file, and then compile as normal. Documentation for gnatprep is in the GNAT User's Guide. Obviously, you change "Compile_Target := XBox" to "Compile_Target := Playstation" to recompile for a different target. The idea is to minimise the number of times you use a $ macro or #if in your source files, within reason, and put as much as possible into the different specific packages. Things tend to be easier to debug this way. You may find that you do not have to use gnatprep at all, but instead you could just have a separate file "target_specific.ads" which contains the two lines: with Stuff_For_XBox; package Target_Specific renames Stuff_For_XBox; which you simply change to: with Stuff_For_Playstation; package Target_Specific renames Stuff_For_Playstation; in order to recompile for a different target. -- HTH Nick Roberts