comp.lang.ada
 help / color / mirror / Atom feed
* Turning off "Unit xxx not referenced" warnings?
@ 2004-10-29  9:51 ggroups
  2004-10-29 10:54 ` Martin Dowie
  2004-10-29 18:56 ` Jeffrey Carter
  0 siblings, 2 replies; 9+ messages in thread
From: ggroups @ 2004-10-29  9:51 UTC (permalink / raw)


I have a file which with's a bunch of other files purely to force their
elaboration.
As a result, I get a number of "Unit xxx not referenced" warnings.  Is
there any way to get rid of them?
There's a compiler switch which turns the warning off, but I'd prefer
to do it on a per-file basis.  Is there not a pragma or something for
this?

Thanks
Jon




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

* Re: Turning off "Unit xxx not referenced" warnings?
  2004-10-29  9:51 Turning off "Unit xxx not referenced" warnings? ggroups
@ 2004-10-29 10:54 ` Martin Dowie
  2004-10-29 14:22   ` Nick Roberts
  2004-10-29 18:56 ` Jeffrey Carter
  1 sibling, 1 reply; 9+ messages in thread
From: Martin Dowie @ 2004-10-29 10:54 UTC (permalink / raw)


ggroups@steelskies.com wrote:
> I have a file which with's a bunch of other files purely to force
> their elaboration.
> As a result, I get a number of "Unit xxx not referenced" warnings.  Is
> there any way to get rid of them?
> There's a compiler switch which turns the warning off, but I'd prefer
> to do it on a per-file basis.  Is there not a pragma or something for
> this?

For GNAT,

pragma Warnings (Off, <unit_name>);

see section "1. Implementation Defined Pragmas" of the GNAT Reference
Manual.

Cheers

-- Martin






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

* Re: Turning off "Unit xxx not referenced" warnings?
  2004-10-29 10:54 ` Martin Dowie
@ 2004-10-29 14:22   ` Nick Roberts
  2004-10-29 17:47     ` Martin Dowie
  0 siblings, 1 reply; 9+ messages in thread
From: Nick Roberts @ 2004-10-29 14:22 UTC (permalink / raw)


Martin Dowie wrote:

> ggroups@steelskies.com wrote:
> 
>>I have a file which with's a bunch of other files purely to force
>>their elaboration.
>>As a result, I get a number of "Unit xxx not referenced" warnings.  Is
>>there any way to get rid of them?
>>There's a compiler switch which turns the warning off, but I'd prefer
>>to do it on a per-file basis.  Is there not a pragma or something for
>>this?
> 
> 
> For GNAT,
> 
> pragma Warnings (Off, <unit_name>);
> 
> see section "1. Implementation Defined Pragmas" of the GNAT Reference
> Manual.

Also see pragma Unreferenced ibid.

-- 
Nick Roberts



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

* Re: Turning off "Unit xxx not referenced" warnings?
  2004-10-29 14:22   ` Nick Roberts
@ 2004-10-29 17:47     ` Martin Dowie
  2004-10-30 14:51       ` Simon Wright
  0 siblings, 1 reply; 9+ messages in thread
From: Martin Dowie @ 2004-10-29 17:47 UTC (permalink / raw)


"Nick Roberts" <nick.roberts@acm.org> wrote in message 
news:2uf20fF2au91oU1@uni-berlin.de...
>> For GNAT,
>>
>> pragma Warnings (Off, <unit_name>);
>>
>> see section "1. Implementation Defined Pragmas" of the GNAT Reference
>> Manual.
>
> Also see pragma Unreferenced ibid.

Yes, I've noticed that newer code coming out of ACT uses "Warnings (Off" 
rather than "Unreferenced" - no idea why... 





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

* Re: Turning off "Unit xxx not referenced" warnings?
  2004-10-29  9:51 Turning off "Unit xxx not referenced" warnings? ggroups
  2004-10-29 10:54 ` Martin Dowie
@ 2004-10-29 18:56 ` Jeffrey Carter
  2004-11-03  0:54   ` Georg Bauhaus
  1 sibling, 1 reply; 9+ messages in thread
From: Jeffrey Carter @ 2004-10-29 18:56 UTC (permalink / raw)


ggroups@steelskies.com wrote:
> I have a file which with's a bunch of other files purely to force their
> elaboration.
> As a result, I get a number of "Unit xxx not referenced" warnings.  Is
> there any way to get rid of them?
> There's a compiler switch which turns the warning off, but I'd prefer
> to do it on a per-file basis.  Is there not a pragma or something for
> this?

A portable way is to mention each in a pragma Elaborate (or 
Elaborate_Body). That may be a good way to do it, since it emphasizes 
that they are there in order to be elaborated.

-- 
Jeff Carter
"I like it when the support group complains that they have
insufficient data on mean time to repair bugs in Ada software."
Robert I. Eachus
91




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

* Re: Turning off "Unit xxx not referenced" warnings?
  2004-10-29 17:47     ` Martin Dowie
@ 2004-10-30 14:51       ` Simon Wright
  2004-11-02  9:21         ` Alex R. Mosteo
  0 siblings, 1 reply; 9+ messages in thread
From: Simon Wright @ 2004-10-30 14:51 UTC (permalink / raw)


"Martin Dowie" <martin.dowie@btopenworld.com> writes:

> "Nick Roberts" <nick.roberts@acm.org> wrote in message 
> news:2uf20fF2au91oU1@uni-berlin.de...
> >> For GNAT,
> >>
> >> pragma Warnings (Off, <unit_name>);
> >>
> >> see section "1. Implementation Defined Pragmas" of the GNAT Reference
> >> Manual.
> >
> > Also see pragma Unreferenced ibid.
> 
> Yes, I've noticed that newer code coming out of ACT uses "Warnings (Off" 
> rather than "Unreferenced" - no idea why... 

I thought Unreferenced (X) was newer than Warnings (Off, X)?

The good thing about Unreferenced is that you get a warning if you do
access the thing.

The slightly confusing thing is that it sort-of means "read": eg,
declaring a BC lock, which locks during elaboration,

  L : Lock (Some_Semaphore'Access);
  pragma Unreferenced (L);

-- 
Simon Wright                               100% Ada, no bugs.



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

* Re: Turning off "Unit xxx not referenced" warnings?
  2004-10-30 14:51       ` Simon Wright
@ 2004-11-02  9:21         ` Alex R. Mosteo
  2004-11-02 21:58           ` Simon Wright
  0 siblings, 1 reply; 9+ messages in thread
From: Alex R. Mosteo @ 2004-11-02  9:21 UTC (permalink / raw)


Simon Wright wrote:
> "Martin Dowie" <martin.dowie@btopenworld.com> writes:
> 
> 
>>"Nick Roberts" <nick.roberts@acm.org> wrote in message 
>>news:2uf20fF2au91oU1@uni-berlin.de...
>>
>>>>For GNAT,
>>>>
>>>>pragma Warnings (Off, <unit_name>);
>>>>
>>>>see section "1. Implementation Defined Pragmas" of the GNAT Reference
>>>>Manual.
>>>
>>>Also see pragma Unreferenced ibid.
>>
>>Yes, I've noticed that newer code coming out of ACT uses "Warnings (Off" 
>>rather than "Unreferenced" - no idea why... 
> 
> 
> I thought Unreferenced (X) was newer than Warnings (Off, X)?
> 
> The good thing about Unreferenced is that you get a warning if you do
> access the thing.
> 
> The slightly confusing thing is that it sort-of means "read": eg,
> declaring a BC lock, which locks during elaboration,
> 
>   L : Lock (Some_Semaphore'Access);
>   pragma Unreferenced (L);

But Unreferenced doesn't work for packages, I tried it... maybe that's 
the reason for using Warnings.



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

* Re: Turning off "Unit xxx not referenced" warnings?
  2004-11-02  9:21         ` Alex R. Mosteo
@ 2004-11-02 21:58           ` Simon Wright
  0 siblings, 0 replies; 9+ messages in thread
From: Simon Wright @ 2004-11-02 21:58 UTC (permalink / raw)


"Alex R. Mosteo" <devnull@mailinator.com> writes:

> But Unreferenced doesn't work for packages, I tried it... maybe that's
> the reason for using Warnings.

I thought it did -- oh well

One reason for not using Unreferenced is that you (now) get problems
with nested generics; in the BCs,

   generic
      type Item is private;
      with function "=" (L, R : Item) return Boolean is <>;
   package BC.Containers is

ends up complaining about the "=" which happens not to be referenced
at this level.

If you use Unreferenced, you get warnings when it is in fact used in
child packages. Hmph. (this is 5.02a1 behaviour, may not be in public
releases)

-- 
Simon Wright                               100% Ada, no bugs.



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

* Re: Turning off "Unit xxx not referenced" warnings?
  2004-10-29 18:56 ` Jeffrey Carter
@ 2004-11-03  0:54   ` Georg Bauhaus
  0 siblings, 0 replies; 9+ messages in thread
From: Georg Bauhaus @ 2004-11-03  0:54 UTC (permalink / raw)


Jeffrey Carter <spam@spam.com> wrote:

: A portable way is to mention each in a pragma Elaborate (or 
: Elaborate_Body). That may be a good way to do it, since it emphasizes 
: that they are there in order to be elaborated.

The portability gained cannot be stressed enough, I think. When
a pragma identifier is known by two compilers that expect a different
argument list, chances are that you can no longer compile programs using
one of the compilers. (Pragma Unsuppress is currently one of them, pragma
Linker_Options should IMHO immediately be rubbed out everywhere and
replaced with proper project configuration files or similar.)

Abandon portability just for the luxury of not seeing a particular
warning with some versions of one Ada compiler? (A compile log without
warnings isn't necessarily an indication of a correct program, is it?)

Georg



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

end of thread, other threads:[~2004-11-03  0:54 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-29  9:51 Turning off "Unit xxx not referenced" warnings? ggroups
2004-10-29 10:54 ` Martin Dowie
2004-10-29 14:22   ` Nick Roberts
2004-10-29 17:47     ` Martin Dowie
2004-10-30 14:51       ` Simon Wright
2004-11-02  9:21         ` Alex R. Mosteo
2004-11-02 21:58           ` Simon Wright
2004-10-29 18:56 ` Jeffrey Carter
2004-11-03  0:54   ` Georg Bauhaus

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