comp.lang.ada
 help / color / mirror / Atom feed
* Conditonal compilation
@ 1996-04-02  0:00 Peter Hermann
  1996-04-02  0:00 ` Laurent Guerby
  1996-04-03  0:00 ` Laurent Guerby
  0 siblings, 2 replies; 5+ messages in thread
From: Peter Hermann @ 1996-04-02  0:00 UTC (permalink / raw)


Are there any portable means for conditional compilation in Ada?
How many?
(e.g. to circumvent Ada95 constructs)

--
Peter Hermann  Tel:+49-711-685-3611 Fax:3758 ph@csv.ica.uni-stuttgart.de
Pfaffenwaldring 27, 70569 Stuttgart Uni Computeranwendungen
Team Ada: "C'mon people let the world begin" (Paul McCartney)




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Conditonal compilation
  1996-04-02  0:00 Conditonal compilation Peter Hermann
@ 1996-04-02  0:00 ` Laurent Guerby
  1996-04-02  0:00   ` Robert A Duff
  1996-04-03  0:00 ` Laurent Guerby
  1 sibling, 1 reply; 5+ messages in thread
From: Laurent Guerby @ 1996-04-02  0:00 UTC (permalink / raw)


[-- 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)




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Conditonal compilation
  1996-04-02  0:00 ` Laurent Guerby
@ 1996-04-02  0:00   ` Robert A Duff
  0 siblings, 0 replies; 5+ messages in thread
From: Robert A Duff @ 1996-04-02  0:00 UTC (permalink / raw)


In article <4xrau6d0l6.fsf@leibniz.enst-bretagne.fr>,
Laurent Guerby <Laurent.Guerby@enst-bretagne.fr> wrote:
>--  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.) ...

Looks like macro preprocessing, to me.

>   Ada   can be a  portable language  without  too much external tools
>(like preprocessors ands Makefiles) ;-).

- Bob




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Conditonal compilation
  1996-04-02  0:00 Conditonal compilation Peter Hermann
  1996-04-02  0:00 ` Laurent Guerby
@ 1996-04-03  0:00 ` Laurent Guerby
  1996-04-03  0:00   ` Peter Hermann
  1 sibling, 1 reply; 5+ messages in thread
From: Laurent Guerby @ 1996-04-03  0:00 UTC (permalink / raw)


Robert A Duff writes
: In article <4xrau6d0l6.fsf@leibniz.enst-bretagne.fr>,
: Laurent Guerby <Laurent.Guerby@enst-bretagne.fr> wrote:
: >--  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.) ...
: 
: Looks like macro preprocessing, to me.

   You're right saying it looks like a macro  processing hack, since I
added it for Makefile lovers. The "--%x11" is here to allow an user to
configure the  software without editing the Ada  file (to  be honnest,
it's to simplify the regexps in the Makefile, and  to avoid the use of
m4 and configure for  such a simple thing  ;-). In this case,  I added
the Makefile only for the release. And here is the main target :

# targets
all:
        @echo "Please check the README file before compiling."
        @echo "Available targets:"
        @echo "   clean"
        @echo "   distclean"
        @echo "   strip"
        @echo "   dart"
        @echo "   true-dart"
        @echo "   use-default"
        @echo "   use-x11"
        @echo "   dont-use-x11"
        @echo "   use-tasking"
        @echo "   dont-use-tasking"

   ;-).

   But, the prefered  way to  configure the software   is to edit  the
configuration file  by  hand, commenting  out such  declaration  (with
GNAT, in the gnat.adc file), staying in the Ada world.

   That's like editing config.h,  but there's no  macro at all, and no
ifdefs  at any place  in the  entire source. By  default, the software
will work  on  every  platform where  you  can  get a  working  Ada 95
compiler without   any macro,  and  any ifdef.  If you   want to  take
advantage of tasking  or X11, you have  to comment out one declaration
each time in one single file. 

   BTW, If you find any   simpler way of configuring software,  please
tell us ;-).

: >   Ada   can be a  portable language  without  too much external tools
: >(like preprocessors ands Makefiles) ;-).

   See above ;-)

: - Bob

-- 
--  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)




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Conditonal compilation
  1996-04-03  0:00 ` Laurent Guerby
@ 1996-04-03  0:00   ` Peter Hermann
  0 siblings, 0 replies; 5+ messages in thread
From: Peter Hermann @ 1996-04-03  0:00 UTC (permalink / raw)


Laurent Guerby (Laurent.Guerby@enst-bretagne.fr) wrote:
: Robert A Duff writes

Thank you both, Laurent and Bob.
I can't feed an Ada83 with Ada95 constructs, of course.   :-(

--
Peter Hermann  Tel:+49-711-685-3611 Fax:3758 ph@csv.ica.uni-stuttgart.de
Pfaffenwaldring 27, 70569 Stuttgart Uni Computeranwendungen
Team Ada: "C'mon people let the world begin" (Paul McCartney)




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1996-04-03  0:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-04-02  0:00 Conditonal compilation Peter Hermann
1996-04-02  0:00 ` Laurent Guerby
1996-04-02  0:00   ` Robert A Duff
1996-04-03  0:00 ` Laurent Guerby
1996-04-03  0:00   ` Peter Hermann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox