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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e60edb8dc1d5e3b3 X-Google-Attributes: gid103376,public From: Laurent.Guerby@enst-bretagne.fr (Laurent Guerby) Subject: Re: Conditonal compilation Date: 1996/04/02 Message-ID: <4xrau6d0l6.fsf@leibniz.enst-bretagne.fr>#1/1 X-Deja-AN: 145450453 distribution: world sender: guerby@leibniz.enst-bretagne.fr references: <4jrehm$489q@info4.rus.uni-stuttgart.de> content-type: text/plain; charset=US-ASCII 14: 45:10 GMT organization: Telecom Bretagne mime-version: 1.0 newsgroups: comp.lang.ada Date: 1996-04-02T00:00:00+00:00 List-Id: Peter Hermann writes : Are there any portable means for conditional compilation in Ada? : How many? : (e.g. to circumvent Ada95 constructs) You can use a boolean or enumeration constant defined in a "portability" (hum, macros are not so far ;-) package, together with "if" or "case" statements and let the optimization to the compiler. That's the cleanest way I know of doing it (preserves the full semantic of Ada, macros are far away ;-). If your "construct" is a compilation unit, you can use the pragma Source_File_Name which is a GNAT specific pragma (for now), and the gnat.adc file (the place for configuration pragmas with GNAT, I don't know for other compilers), and provide different bodies. Example : --------- X11 support -- If you want to have X11 support, and to use the -w, --window command -- line option, uncomment the following pragma. You'll also need to check -- the documentation of DART about the X-Binding before compiling. -- pragma Source_File_Name --%x11 -- (Unit_Name => Images.Display, --%x11 -- Body_File_Name => "x11.images-display.adb"); --%x11 (The "--%x11" is here for Makefile easy-auto-configuration-sed hacks.) Just provide a dummy images-display.adb that raises an "Unimplemented" exception when a routine is called. We used this method for X11/no X11 stuff and tasking/no tasking stuff in the DART project (not released yet). But it can easily be generalized, and if the pragma Source_File_Name is adopted by other vendors (I hope so), it will provide a clean solution (together with boolean/enumerates) to most configuration problems *staying in the Ada 95 language*, without specific Makefiles everywhere (horrors most of the time, if there's more than one target). Ada can be a portable language without too much external tools (like preprocessors ands Makefiles) ;-). Hope this helps, -- -- Laurent Guerby, student at Telecom Bretagne (France), Team Ada -- "Use the Source, Luke. The Source will be with you, always (GPL)" -- http://www-eleves.enst-bretagne.fr/~guerby/ (GATO Project) -- Try GNAT, the GNU Ada 95 compiler (ftp://cs.nyu.edu/pub/gnat)