From: Per Sandberg <per.sandberg@bredband.net>
Subject: Re: conditionnal compilation
Date: Thu, 14 May 2009 06:20:13 +0200
Date: 2009-05-14T06:20:13+02:00 [thread overview]
Message-ID: <IMNOl.108414$5J5.51810@newsfe29.ams2> (raw)
In-Reply-To: <4259b442-6772-4527-989a-b20e1641b8d0@g20g2000vba.googlegroups.com>
More on the above them when using GNAT project files:
When the number of target specific files is moderate:
--------------------------------------------------------------------
project my is
-- Both the spec and body of My_Unit is target specific
-- But i would recommend to keep the target specific parts
-- as isolated as possible.
type OS_Type is ("Windows_NT","Linux");
OS : OS_Type := external("OS","Linux");
package Naming is
case OS is
when "Linux" =>
for Implementation("My.Unit") use "my-unit__Linux.adb";
for Specification ("My.Unit") use "my-unit__Linux.ads";
when "Windows_NT" =>
for Implementation("My.Unit") use "my-unit__Win32.adb";
for Specification ("My.Unit") use "my-unit__Win32.ads";
end case;
end Naming;
end my;
---------------------------------------------------------------------
When the number of target specific files is a bit larger:
--------------------------------------------------------------------
project my is
-- The target specific files are kept in separate directories.
type OS_Type is ("Windows_NT","Linux");
OS : OS_Type := external("OS","Linux");
for Source_Dirs use ("src");
case OS is
when "Linux" =>
For Source_Dirs use project'Source_Dirs & ("src/Linux");
when "Windows_NT" =>
For Source_Dirs use project'Source_Dirs & ("src/Win32");
end case;
end my;
--------------------------------------------------------------------
I would advice to one of the above schema's since they keep things
understandable and try to stay with the first since Ada is usually is
very portable.
But if conditional compilation is a requirement (in my opinion a very
stupid one and this one is very compiler specific) you could read about
it in:
The GNAT users guide chapters:
16. Preprocessing Using gnatprep
3.2.17 Integrated Preprocessing
The chapter references may not be 100% correct but anyway.
/Project files are an engineers best friend.
/Per
guerrier.cachalot@gmail.com wrote:
> Hi my friends
> Now that I know Ada has not built'in support for conditional
> compilation such a full-featured preprocessor, I would like know what
> should I use instead ?
> I precise I'm just a little beginner who doesn't want to compile
> anything .
> What really happend when I specify "--no-ssl" at some Ada-written
> program compilation ?
next prev parent reply other threads:[~2009-05-14 4:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-13 20:08 conditionnal compilation guerrier.cachalot
2009-05-13 21:51 ` Jeffrey R. Carter
2009-05-14 3:06 ` Hibou57 (Yannick Duchêne)
2009-05-14 3:20 ` anon
2009-05-14 4:20 ` Per Sandberg [this message]
2009-05-14 7:17 ` guerrier.cachalot
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox