comp.lang.ada
 help / color / mirror / Atom feed
* What should be convention C?
@ 2014-07-24 16:34 Victor Porton
  2014-07-24 16:50 ` Niklas Holsti
  0 siblings, 1 reply; 2+ messages in thread
From: Victor Porton @ 2014-07-24 16:34 UTC (permalink / raw)


Suppose we need to interface a procedure C_Procedure which receives a 
pointer to a record C_Record.

Is Convention=>C needed for both of the below? Or just to one (which?)

type C_Record is
   record
      A: unsigned;
      B: unsigned;
   end record
     with Convention=>C;

procedure C_Procedure(X: access C_Record)
  with Convention=>C;

-- 
Victor Porton - http://portonvictor.org

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

* Re: What should be convention C?
  2014-07-24 16:34 What should be convention C? Victor Porton
@ 2014-07-24 16:50 ` Niklas Holsti
  0 siblings, 0 replies; 2+ messages in thread
From: Niklas Holsti @ 2014-07-24 16:50 UTC (permalink / raw)


On 14-07-24 19:34 , Victor Porton wrote:
> Suppose we need to interface a procedure C_Procedure which receives a 
> pointer to a record C_Record.
> 
> Is Convention=>C needed for both of the below? Or just to one (which?)

Both.

> type C_Record is
>    record
>       A: unsigned;
>       B: unsigned;
>    end record
>      with Convention=>C;
> 
> procedure C_Procedure(X: access C_Record)
>   with Convention=>C;

In order to link with C_Procedure, you must Import C_Procedure.

In order to ensure use the C calling convention, you must specify
Convention(C) for C_Procedure.

RM B.1(26/3) then says that the result and parameter types of
C_Procedure must be "compatible" with Convention(C).

RM B.1(12) and its sub-bullets then say, essentially, that Comvention(C)
must be specified for the result and parameter types, thus for C_Record,
unless the implementation somehow implicitly permits C_Record as
compatible with Convention(C), on which one should not rely.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
      .      @       .


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

end of thread, other threads:[~2014-07-24 16:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-24 16:34 What should be convention C? Victor Porton
2014-07-24 16:50 ` Niklas Holsti

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