comp.lang.ada
 help / color / mirror / Atom feed
* Platform specific sources
@ 1992-10-21 20:47 dog.ee.lbl.gov!hellgate.utah.edu!cs.utexas.edu!zaphod.mps.ohio-state.edu!
  0 siblings, 0 replies; 2+ messages in thread
From: dog.ee.lbl.gov!hellgate.utah.edu!cs.utexas.edu!zaphod.mps.ohio-state.edu! @ 1992-10-21 20:47 UTC (permalink / raw)


Is there a "superior" method for supporting platform specific
features in the same source code using Ada?  I would prefer if
the method didn't require a tool which doesn't come with the
standard Ada toolset (such as cpp, etc.).  I am developing Ada
software which will eventually run on a PC using Alsys, a Sun
using SunAda (VADS), and a DEC.  There will be host OS specific
code which in C would normally be handled via cpp.  Should I
ftp the Ada source for an "Ada cpp" and then build it for each
of my development platforms?  What is the standard practice in
the Ada world?

Sorry for my ignorance, I am a longtime C'er and didn't see
anything in the FAQ.  Thanks in advance.

----------------------------------------------------------------------------
Timothy J. Barton                         tim@trident.datasys.swri.edu
Senior Research Analyst                   (512) 522-3540
Southwest Research Institute (SwRI)       (512) 522-5499  (Fax)   
San Antonio, Texas  78228-0510

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

* Re: Platform specific sources
@ 1992-10-22 16:56 Bob Kitzberger
  0 siblings, 0 replies; 2+ messages in thread
From: Bob Kitzberger @ 1992-10-22 16:56 UTC (permalink / raw)


tim@trident.datasys.swri.edu (Timothy J. Barton) writes:

>Is there a "superior" method for supporting platform specific
>features in the same source code using Ada?

IMHO, the superior method is to encapsulate target-specific code
into a (sub)unit (package, procedure, etc.) that can be separately compiled.

Two main approaches:

A. Subunits

    package My_System is

      package Target_Specifics is separate;
    ...

  Then, have 'n' version of the separate package Target_Specifics, in
  separate, uniquely named files (Target_sparc.ada, Target_mc680x0.ada,
  etc.)  Of course, only compile the file that matches the target you
  are building your system for.

  (caveat: there are performance issues related to use of subunits.
   See "Optimization Issues Relating to Subunits", Tom Burger, Ada Letters
   May/June 1992.)

B. Packages

       with Target_Specifics;
       package My_System is ...

   As above, write a version of Target_Specifics for each target
   you are supporting.
   


For some target dependencies, it can be difficult to encapsulate the
dependencies into units or subunits.  For finer granularity of
conditional compilation, use constants:

     type Target is ( MC680x0, 80x86, SPARC);

     This_Target : constant Target := MC680x0;

     ...

     if This_Target = SPARC then
        ...
     etc.

  Reasonable compilers will optimize away code inside of conditional
  statements, if the conditional statically evaluates to false.


        .Bob.
----------------
Bob Kitzberger          VisiCom Laboratories, Inc.
rlk@visicom.com         10052 Mesa Ridge Court, San Diego CA 92121 USA
                        +1 619 457 2111    FAX +1 619 457 0888

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

end of thread, other threads:[~1992-10-22 16:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1992-10-22 16:56 Platform specific sources Bob Kitzberger
  -- strict thread matches above, loose matches on Subject: below --
1992-10-21 20:47 dog.ee.lbl.gov!hellgate.utah.edu!cs.utexas.edu!zaphod.mps.ohio-state.edu!

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