comp.lang.ada
 help / color / mirror / Atom feed
From: Ludovic Brenta <ludovic.brenta@insalien.org>
Subject: Re: Preprocessor functionality equivalent ideas needed
Date: 10 Dec 2003 22:41:44 +0100
Date: 2003-12-10T22:41:44+01:00	[thread overview]
Message-ID: <m3he08tko7.fsf@insalien.org> (raw)
In-Reply-To: Hpp3r9.6L0@news.boeing.com

"Greg Milford" <gregory.a.milford@boeing.com> writes:

> Hello
> 
> I checked the FAQ for this group and did not get an answer to this.  I know
> Ada does not have a preprocessor, so how should I go about maintaining
> changes to a common code base that needs to be built under two different
> configurations?
> 
> Am I left with using Global variables or has a better method been used?  I
> am new to Ada so be kind :)
> 
> Greg

GNAT does have a preprocessor called gnatprep, but it is not part of
the language standard.  If you cannot or won't use it, the usual way
to deal with configuration management issues such as you describe is
to write two or more different bodies for a single package
specification, and let the build scripts (Makefiles or such) compile
one or the other for each particular configuration.  Of course, you'll
want to isolate all configuration-dependent stuff into a separate
package which you keep as small as possible; this is usual software
engineering practice.

There are various ways to achieve this.  For example, assume you have:

a.ads   the package specification
a1.adb  package body for target 1
a2.adb  package body for target 2

Your makefiles could select one of the *.adb files and symlink it to
a.adb; then the compiler finds the proper file and compiles it.  This
is in fact the approach used by GNAT itself.

Another approach could be to simulate a preprocessor with sed or perl
scripts.

HTH

-- 
Ludovic Brenta.



  reply	other threads:[~2003-12-10 21:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-10 20:04 Preprocessor functionality equivalent ideas needed Greg Milford
2003-12-10 21:41 ` Ludovic Brenta [this message]
2003-12-11 17:12   ` sed and perl - yuck [Was Re: Preprocessor functionality equivalent ideas needed] Martin Krischik
2003-12-16  0:40     ` Waldek Hebisch
2003-12-16 20:52       ` Martin Krischik
2003-12-10 22:29 ` Preprocessor functionality equivalent ideas needed Georg Bauhaus
2003-12-12  5:52   ` Simon Wright
2003-12-11  1:07 ` Jeffrey Carter
2003-12-11 13:34   ` Marin David Condic
2003-12-11 17:49     ` Jeffrey Carter
2003-12-11  5:39 ` Steve
2003-12-11 16:59 ` Martin Krischik
  -- strict thread matches above, loose matches on Subject: below --
2003-12-11 12:52 Lionel.DRAGHI
2003-12-11 15:51 Lionel.DRAGHI
replies disabled

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