comp.lang.ada
 help / color / mirror / Atom feed
From: "Björn Lundin" <b.f.lundin@gmail.com>
Subject: Re: converting pointer to value
Date: Fri, 5 Mar 2021 08:10:35 +0100	[thread overview]
Message-ID: <s1slhb$hkn$1@dont-email.me> (raw)
In-Reply-To: <02709d96-50fe-4e87-bdb5-4f430fa2717an@googlegroups.com>

Den 2021-03-04 kl. 17:55, skrev Shark8:
> On Thursday, March 4, 2021 at 8:59:48 AM UTC-7, björn lundin wrote:
> 
>> this code looks like
>>
>> type SQLSMALLINT is range -(2 ** 15) .. +(2 ** 15) - 1;
>> for SQLSMALLINT'Size use 16;
>>
>> type SQLRETURN is new SQLSMALLINT;
>>
>>
>> how to get the Pvalue as an SQLRETURN?
> 
> Ok, in Ada the creation of a new type, even if only deriving it via NEW, makes a type which is incompatible with the old type.
> Thus you can say TYPE TEMPERATURE IS NEW INTEGER; and TYPE SPEED IS NEW INTEGER; and values of these types are NOT interchangeable even though both have the same internal representation and properties that INTEGER does. The way that you can use these different types together is by casting; given X : SPEED := 3; you can say Y :  TEMPERATURE := SPEED(X); -- which works because they have the same internal representation if they did not have the same representation you would have to use UNCHECKED_CONVERSION.
> 

well, yes.


...


> It means that we don't know what the size of ADDRESS (and thus SQLPOINTER) 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 indication that a simple UNCHECKED_CONVERSION is the wrong answer.

I think I first settle with 64bit.
64bit os and 64 bit compiler

> 
> Try looking at the operations which have SQLPOINTER as a parameter/result.

I did and the only operation usefull here is the mentioned

utility function

    function To_Address (P : SQLPOINTER) return System.Address;



-- 
Björn

      parent reply	other threads:[~2021-03-05  7:10 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-04 15:59 converting pointer to value Björn Lundin
2021-03-04 16:50 ` Dmitry A. Kazakov
2021-03-05  7:06   ` Björn Lundin
2021-03-05  7:44     ` Dmitry A. Kazakov
2021-03-05  9:10       ` Björn Lundin
2021-03-04 16:55 ` Shark8
2021-03-04 17:35   ` Dmitry A. Kazakov
2021-03-04 19:38     ` Shark8
2021-03-04 21:27       ` Dmitry A. Kazakov
2021-03-05  8:58         ` Björn Lundin
2021-03-05  8:54     ` Björn Lundin
2021-03-05 11:02     ` Björn Lundin
2021-03-05 11:57       ` Björn Lundin
2021-03-05 14:00         ` Dmitry A. Kazakov
2021-03-09 12:07     ` [SOLVED] " Björn Lundin
2021-03-04 20:09   ` Simon Wright
2021-03-04 21:00     ` Shark8
2021-03-05  8:59       ` Björn Lundin
2021-03-05  7:10   ` Björn Lundin [this message]
replies disabled

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