comp.lang.ada
 help / color / mirror / Atom feed
From: Mark Wilson <markwilson@wilsonnet.technology>
Subject: Re: Odd Behaviour
Date: Tue, 18 Jan 2022 04:18:54 -0800 (PST)	[thread overview]
Message-ID: <13fa1a0d-eeed-4f44-a1ec-cace658fec0dn@googlegroups.com> (raw)
In-Reply-To: <e6a624b6-e754-4ee5-ad7b-c82f7ef1accan@googlegroups.com>

On Tuesday, January 18, 2022 at 12:08:16 PM UTC, Mark Wilson wrote:
> On Tuesday, January 18, 2022 at 11:51:36 AM UTC, Mark Wilson wrote: 
> > On Tuesday, January 18, 2022 at 11:48:23 AM UTC, Jeffrey R.Carter wrote: 
> > > On 2022-01-18 12:05, Mark Wilson wrote: 
> > > > 
> > > > then an error is raised: 'warning: Valued_Procedure has no effect for convention Ada [enabled by default]' 
> > > The GNAT RM says of pragma Import_Valued_Procedure 
> > > 
> > > "Note that it is important to use this pragma in conjunction with a separate 
> > > pragma Import that specifies the desired convention, since otherwise the default 
> > > convention is Ada, which is almost certainly not what is required." 
> > > 
> > > What happens if you replace the import aspects with pragma Import? 
> > > -- 
> > > Jeff Carter 
> > > "Monsieur Arthur King, who has the brain of a duck, you know." 
> > > Monty Python & the Holy Grail 
> > > 09 
> > Tried pragma Import, and even pragma Convention, so, for instance, 
> > procedure SQLAllocHandle 
> > (Result : out SQLRETURN; 
> > HandleType : in SQL_HANDLE_TYPE; 
> > InputHandle : in SQLHANDLE; 
> > OutputHandlePtr : in out SQLHANDLE) 
> > with 
> > Pre => (Handletype = SQL_Handle_Env); 
> > 
> > pragma Import (C, SQLAllocHandle, "SQLAllocHandle"); 
> > pragma Import_Valued_Procedure (SQLAllocHandle); 
> > 
> > Fails with the same warning. Take the 'pre' out and it works fine.
> Even tried (which to be fair is a bit of a long shot),
> procedure SQLAllocHandle 
> (Result : out SQLRETURN; 
> HandleType : in SQL_HANDLE_TYPE; 
> InputHandle : in SQLHANDLE;
> OutputHandlePtr : in out SQLHANDLE); 
> -- with 
> -- Pre => (Handletype = SQL_Handle_Env); 
> 
> 
> pragma Import (C, SQLAllocHandle); 
> pragma Import_Valued_Procedure 
> (SQLAllocHandle, "SQLAllocHandle", 
> (SQLRETURN, SQL_HANDLE_TYPE, SQLHANDLE, SQLHANDLE), 
> (Reference, Value, Value, Reference)); 
> 
> Do you think I should file a bug report?

Well, this works - but feels very naughty,

   function SQLAllocHandle
     (HandleType      : in     SQL_HANDLE_TYPE;
      InputHandle     : in     SQLHANDLE;
      OutputHandlePtr : in SQLHANDLE)
     return SQLRETURN;
   --  with
   --    Pre =>   (Handletype = SQL_Handle_Env);
   
   pragma Import (C, SQLAllocHandle);
   pragma Import_Function
     (SQLAllocHandle, "SQLAllocHandle",
      (SQL_HANDLE_TYPE, SQLHANDLE, SQLHANDLE), SQLRETURN,
      (Value, Value, Reference));

However, adding the precondition in results in '<artificial>:(.text+0xb7): undefined reference to `sqlallochandle'''

  reply	other threads:[~2022-01-18 12:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-18 11:05 Odd Behaviour Mark Wilson
2022-01-18 11:16 ` Marius Amado-Alves
2022-01-18 11:21   ` Mark Wilson
2022-01-18 11:24     ` Mark Wilson
2022-01-18 11:28 ` Jeffrey R.Carter
2022-01-18 11:35   ` Mark Wilson
2022-01-18 11:48 ` Jeffrey R.Carter
2022-01-18 11:51   ` Mark Wilson
2022-01-18 12:08     ` Mark Wilson
2022-01-18 12:18       ` Mark Wilson [this message]
2022-01-18 12:27         ` Mark Wilson
2022-01-18 13:50           ` Mark Wilson
2022-01-18 12:25       ` Jeffrey R.Carter
2022-01-18 12:30         ` Mark Wilson
replies disabled

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