comp.lang.ada
 help / color / mirror / Atom feed
* Exclude parts of a package
@ 2013-12-05 20:13 Felix Krause
  2013-12-06  1:58 ` gautier_niouzes
                   ` (6 more replies)
  0 siblings, 7 replies; 17+ messages in thread
From: Felix Krause @ 2013-12-05 20:13 UTC (permalink / raw)


In C, I have the possibility to switch parts of my code on or off with 
preprocessor defines. What would be the Ada way to do something like 
that?

I know that I can use scenario variables with gprbuild. This works well 
if I want to include or exclude whole packages (because I can include 
or exclude certain files), but it does not work if I just want to 
exclude certain subroutines from a package.

Take for example OpenCLAda: The user of the library should be able to 
choose which version of the OpenCL API he wants to use (1.0, 1.1, …). 
This choice should result in subroutines added in newer versions not 
being available.

Excluding newer functionality is vital because if the user just takes 
care about not using it, the wrapper will still link against the newer 
C functions and thus the resulting binary cannot run on a system with 
an older implementation - even though the implementation provides all 
functionality the application needs.

One approach might be to implement all functions that are not part of 
OpenCL 1.0 with "separate", place the implementation files in 
subfolders "1.1", "1.2"… and provide an implementation for older 
versions which raises an exception at runtime. But I'm not satisfacted 
with that approach because the error is already discoverable with 
knowledge available at compile-time.

Is there any better way to do it?

-- 
Felix Krause
http://flyx.org/



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

end of thread, other threads:[~2014-01-02 15:07 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-05 20:13 Exclude parts of a package Felix Krause
2013-12-06  1:58 ` gautier_niouzes
2013-12-06  7:51 ` Chris Moore
2013-12-06  8:04 ` playerdark
2013-12-06 11:14 ` Brian Drummond
2013-12-06 11:14 ` Brian Drummond
2013-12-06 11:41 ` Brian Drummond
2013-12-06 20:48   ` Felix Krause
2013-12-06 21:27     ` Shark8
2013-12-07  8:41       ` Felix Krause
2013-12-07 11:55         ` Brian Drummond
2013-12-08 20:00 ` Stephen Leake
2013-12-12 14:30   ` Marius Amado-Alves
2013-12-13 13:16     ` Felix Krause
2013-12-13 16:17     ` Stephen Leake
2014-01-02 15:06       ` Marius Amado-Alves
2014-01-02 15:07       ` Marius Amado-Alves

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