comp.lang.ada
 help / color / mirror / Atom feed
* Interface Units for Standalone Libraries and units with'ed by the body
@ 2017-02-26 17:35 Scott Loyd
  2017-02-26 19:22 ` Simon Wright
  0 siblings, 1 reply; 6+ messages in thread
From: Scott Loyd @ 2017-02-26 17:35 UTC (permalink / raw)


I have created a standalone library which is called by other Ada code. The problem is that every time I 'with' a package into the body (not the spec!) of the standalone library, GNAT tells me the unit is not in the interface set for the library but is needed by the body. That's true, and why should I care? Callers should not need to have units needed explicitly by the implementation exposed as interface units, should they?

From http://www.cs.fsu.edu/~baker/ada/gnat/html/gnat_ugn_20.html#SEC226
"A Stand-alone Library (abbreviated "SAL") is a library that contains the necessary code to elaborate the Ada units that are included in the library. In contrast with an ordinary library, which consists of all sources, objects and `ALI' files of the library, a SAL may specify a restricted subset of compilation units to serve as a library interface. In this case, the fully self-sufficient set of files will normally consist of an objects archive, the sources of interface units' specs, and the `ALI' files of interface units. If an interface spec contains a generic unit or an inlined subprogram, the body's source must also be provided; if the units that must be provided in the source form depend on other units, the source and `ALI' files of those must also be provided."

I am not using generic units or inlined subprograms so what am I missing here?


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

* Re: Interface Units for Standalone Libraries and units with'ed by the body
  2017-02-26 17:35 Interface Units for Standalone Libraries and units with'ed by the body Scott Loyd
@ 2017-02-26 19:22 ` Simon Wright
  2017-02-26 22:44   ` Scott Loyd
  0 siblings, 1 reply; 6+ messages in thread
From: Simon Wright @ 2017-02-26 19:22 UTC (permalink / raw)


Scott Loyd <loyd.scott@gmail.com> writes:

> The problem is that every time I 'with' a package into the body
> (not the spec!) of the standalone library

I don't understand. Perhaps you could give a little example of what you
mean?


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

* Re: Interface Units for Standalone Libraries and units with'ed by the body
  2017-02-26 19:22 ` Simon Wright
@ 2017-02-26 22:44   ` Scott Loyd
  2017-02-27  8:27     ` Dmitry A. Kazakov
  2017-02-27 14:35     ` Simon Wright
  0 siblings, 2 replies; 6+ messages in thread
From: Scott Loyd @ 2017-02-26 22:44 UTC (permalink / raw)



> I don't understand. Perhaps you could give a little example of what you
> mean?

I will try. When I attempted to extract a small standalone example, everything compiled fine without the error, so now I'm even more confused and not sure even how to reproduce the problem (Ugh!). 

The package Handmade contains the only entry points for the library so I would expect that and any types visible in the exports to be required in the Library_Interface attribute for the project. However, when I use something from another package which is not listed in the Library_Interface in the body of Handmade, I get the error as below:

gprbuild handmade.gpr
gcc -c -gnat12 -g -gnatwa handmade.adb
Error: In library project "Handmade"
         Unit "Handmade_Random" is not in the interface set
         but it is needed by the body of "Handmade"
gprbuild: incomplete Stand-Alone Library interface
[2017-02-26 17:24:27] process exited with status 4, elapsed time: 00.88s

A portion of the code is at http://pastebin.com/pg7ppcDj

Unfortunately, when I take this code alone and compile it I don't get the error so I don't expect to get a lot of help on this one.

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

* Re: Interface Units for Standalone Libraries and units with'ed by the body
  2017-02-26 22:44   ` Scott Loyd
@ 2017-02-27  8:27     ` Dmitry A. Kazakov
  2017-03-04 15:15       ` Scott Loyd
  2017-02-27 14:35     ` Simon Wright
  1 sibling, 1 reply; 6+ messages in thread
From: Dmitry A. Kazakov @ 2017-02-27  8:27 UTC (permalink / raw)


> The package Handmade contains the only entry points for the library
> so  I would expect that and any types visible in the exports to be required
> in the Library_Interface attribute for the project. However, when I use
> something from another package which is not listed in the
> Library_Interface in the body of Handmade,

Is it in another project or from the same project? In my stand-alone 
library all units visible in the interface specification are from other 
projects. I don't know if that could be important.

> A portion of the code is at http://pastebin.com/pg7ppcDj

BTW Library_Auto_Init, if "true" it will deadlock under Windows if you 
use tasking and some other standard Ada means in your program. I worked 
it around by setting it to "false" and doing initialization from 
exported functions on first call.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


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

* Re: Interface Units for Standalone Libraries and units with'ed by the body
  2017-02-26 22:44   ` Scott Loyd
  2017-02-27  8:27     ` Dmitry A. Kazakov
@ 2017-02-27 14:35     ` Simon Wright
  1 sibling, 0 replies; 6+ messages in thread
From: Simon Wright @ 2017-02-27 14:35 UTC (permalink / raw)


Scott Loyd <loyd.scott@gmail.com> writes:

> gprbuild handmade.gpr
> gcc -c -gnat12 -g -gnatwa handmade.adb
> Error: In library project "Handmade"
>          Unit "Handmade_Random" is not in the interface set
>          but it is needed by the body of "Handmade"
> gprbuild: incomplete Stand-Alone Library interface

I get this if I make GameUpdateAndRender inline.


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

* Re: Interface Units for Standalone Libraries and units with'ed by the body
  2017-02-27  8:27     ` Dmitry A. Kazakov
@ 2017-03-04 15:15       ` Scott Loyd
  0 siblings, 0 replies; 6+ messages in thread
From: Scott Loyd @ 2017-03-04 15:15 UTC (permalink / raw)



> BTW Library_Auto_Init, if "true" it will deadlock under Windows if you 
> use tasking and some other standard Ada means in your program. 

That's good to know. Will probably save me a headache down the road. 

> I get this if I make GameUpdateAndRender inline.

Hmmm, this could be the culprit. I have a number of inlines that are only defined in the body (with no spec declaration), but GameUpdateAndRender is not one of them. At this point it is just a mild inconvenience but still an odd problem.

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

end of thread, other threads:[~2017-03-04 15:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-26 17:35 Interface Units for Standalone Libraries and units with'ed by the body Scott Loyd
2017-02-26 19:22 ` Simon Wright
2017-02-26 22:44   ` Scott Loyd
2017-02-27  8:27     ` Dmitry A. Kazakov
2017-03-04 15:15       ` Scott Loyd
2017-02-27 14:35     ` Simon Wright

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