From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.5-pre1 X-Received: by 2002:a37:6491:: with SMTP id y139mr5647257qkb.483.1614886718382; Thu, 04 Mar 2021 11:38:38 -0800 (PST) X-Received: by 2002:a25:6e57:: with SMTP id j84mr9139450ybc.277.1614886718186; Thu, 04 Mar 2021 11:38:38 -0800 (PST) Path: eternal-september.org!reader02.eternal-september.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 4 Mar 2021 11:38:38 -0800 (PST) In-Reply-To: Injection-Info: google-groups.googlegroups.com; posting-host=146.5.2.231; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 146.5.2.231 References: <02709d96-50fe-4e87-bdb5-4f430fa2717an@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: converting pointer to value From: Shark8 Injection-Date: Thu, 04 Mar 2021 19:38:38 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:61468 List-Id: On Thursday, March 4, 2021 at 10:35:01 AM UTC-7, Dmitry A. Kazakov wrote: > On 2021-03-04 17:55, Shark8 wrote:=20 >=20 > >> type SQLPOINTER is private;=20 > > ....=20 > >> private=20 > >> type SQLPOINTER is new System.Storage_Elements.Integer_Address;=20 > >=20 > > And here we have SQLPOINTER, which is private, but which is something o= f the same representation that Integer_Address has; let's assume that the A= DDRESS type is implementation-defined, and a private type. > SQLPOINTER is System.Address. Which is implementation-defined. Even though most programmers would assert that address and integer are the = same thing, this isn't a given; segmented architectures would more naturall= y map to records. > > What does this mean?=20 > > It means that we don't know what the size of ADDRESS (and thus SQLPOINT= ER) actually is, but assuming you're on a 32- or 64-bit machine it's likely= 2 to 4 times as large as the 16-bit SQLSMALLINT-- which is a good indicati= on that a simple UNCHECKED_CONVERSION is the wrong answer. > You need not to know that:=20 >=20 > declare=20 > P : SQLPOINTER :=3D ...;=20 > A : System.Address;=20 > pragma Import (Ada, A);=20 > for A'Address use P'Address;=20 > T : My_Fancy_Object;=20 > pragma Import (Ada, My_Fancy_Object);=20 > for T'Address use A;=20 > begin=20 > ... -- Use T at P None of that addresses the issue that he asked: "how to get the Pvalue as a= n SQLRETURN?" One of these is 16-bits, the other is derived from System.Storage_Elements.= Integer_Address. Sure, you can overlay, and that could be valid in some cases, but I simply = don't have enough information here to say if that would be a valid solution= and it's much more likely that it would be completely unintended.