From: Laurent.Guerby@enst-bretagne.fr (Laurent Guerby)
Subject: Re: Conditonal compilation
Date: 1996/04/02
Date: 1996-04-02T00:00:00+00:00 [thread overview]
Message-ID: <4xrau6d0l6.fsf@leibniz.enst-bretagne.fr> (raw)
In-Reply-To: 4jrehm$489q@info4.rus.uni-stuttgart.de
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=US-ASCII 14: 45:10 GMT, Size: 2269 bytes --]
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)
next prev parent reply other threads:[~1996-04-02 0:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-04-02 0:00 Conditonal compilation Peter Hermann
1996-04-02 0:00 ` Laurent Guerby [this message]
1996-04-02 0:00 ` Robert A Duff
1996-04-03 0:00 ` Laurent Guerby
1996-04-03 0:00 ` Peter Hermann
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox