comp.lang.ada
 help / color / mirror / Atom feed
* Re: Rational Apex and RM 7.4(2)
  1998-08-06  0:00 Rational Apex and RM 7.4(2) x1y2z3
@ 1998-08-06  0:00 ` Robert Dewar
  0 siblings, 0 replies; 2+ messages in thread
From: Robert Dewar @ 1998-08-06  0:00 UTC (permalink / raw)


Andrew says

<<Has anyone else come across this problem (if it is a problem), or are
we doing something "naughty"?

  package A is
    ...
    package B is
       type Foo is private;
       ...
    private
       type Foo is new System.Address;
    end B;

    Bar : constant B.Foo;
    ...
  private
    pragma Import (C, Bar, "C_Bar");
  end A;
>>


You are not doing anything naughty, but you are doing something that not
all compilers may support, since a compiler is given a lot of freedom in
what it implements using pragma Import.

GNAT certainly regards the support of this particular case of pragma
Import as an important one, but it is certainly true that compilers that
are less capable in this area may legitimately choose not to implement
this useful feature. You should complain to your vendor, and make it
clear that you would like them to implement it. It is hard to believe
that it is hard to do, so this is most likely an oversight that can 
easily be corrected.

Robert Dewar
Ada Core Technologies

Note that not even pragma Interface (C, ...) to anything at all is a required
part of the Ada 95 standard, so any time you use pragma Interface , you must
verify that you are using a form of it that is supported by the particular
compiler you intend to use.





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

* Rational Apex and RM 7.4(2)
@ 1998-08-06  0:00 x1y2z3
  1998-08-06  0:00 ` Robert Dewar
  0 siblings, 1 reply; 2+ messages in thread
From: x1y2z3 @ 1998-08-06  0:00 UTC (permalink / raw)


Hi,

we have some code containing deferred constants which are imported from
C. Gnat has no trouble with this, however I was told by a client that
their Rational Apex compiler did not like those constants (I don't know
of any specific error messages).

The RM says in 7.4(2)  "A deferred constant declaration requires a
completion, which shall be a full constant declaration ([...]), or a
pragma Import (see Annex B).", so what we are doing seems ok.

Has anyone else come across this problem (if it is a problem), or are
we doing something "naughty"?

  package A is
    ...
    package B is
       type Foo is private;
       ...
    private
       type Foo is new System.Address;
    end B;

    Bar : constant B.Foo;
    ...
  private
    pragma Import (C, Bar, "C_Bar");
  end A;

A workaround for Apex is to declare a variable in A's private part,
Import that and use the variable to complete the constant:

  private
    Temp_Bar : B.Foo;
    pragma Import (C, Temp_Bar, "C_Bar");
    Bar : constant B.Foo := Temp_Bar;
  end A;

This gets rather verbose when setting up a dozen constants. Any
better ideas?

Andrew.

--
+----------------------------------------------------------------------+
| Andrew Lynch, MEng (York) / lynch@cci.de | Run, run, as fast as you  |
| CCI GmbH                 /alynch@iee.org | can. You can't catch me,  |
| Lohberg 10       _______/ lyncha@acm.org | I'm the gingerbeard man!  |
| D-49716 Meppen  / Tel. ++49 5931 805-243 |       .sig by Anna Gramme |
+----------------------------------------------------------------------+

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum




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

end of thread, other threads:[~1998-08-06  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-08-06  0:00 Rational Apex and RM 7.4(2) x1y2z3
1998-08-06  0:00 ` Robert Dewar

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