From: visicom!amstel!rlk@nosc.mil (Bob Kitzberger)
Subject: Re: Platform specific sources
Date: 22 Oct 92 16:56:50 GMT [thread overview]
Message-ID: <rlk.719773010@amstel> (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
next reply other threads:[~1992-10-22 16:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1992-10-22 16:56 Bob Kitzberger [this message]
-- strict thread matches above, loose matches on Subject: below --
1992-10-21 20:47 Platform specific sources dog.ee.lbl.gov!hellgate.utah.edu!cs.utexas.edu!zaphod.mps.ohio-state.edu!
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox