[Gambas-user] unsigned int datatype for external function

T Lee Davidson t.lee.davidson at gmail.com
Sun Jun 10 19:35:13 CEST 2018


An integer type is obviously not wide enough.

I don't know why Jussi said that a long type won't help you. A 'long' is 63+1 bits wide; certainly wide enough to hold a 32-bit
unsigned integer.


-- 
Lee


On 06/10/2018 01:27 PM, Demosthenes Koptsis wrote:
> i dont understand,
> 
> i have an external function from libc and i see size_t as datatype.
> 
> size_t is unsigned integer
> 
> on function declaration what should i set for size_t, AS Integer or AS Long?
> 
> for example i have this
> 
> 'void setbuffer (FILE *stream, char *buf, size_t size)
> Public Extern setbuffer(stream As Pointer, buf As Pointer, size As Integer) 'FIXME size_t int or long?
> 
> 
> On 06/10/2018 07:45 PM, Jussi Lahtinen wrote:
>> So, it's 32bit integer. Most likely the library reads only 32 bit from the memory, and thus "long" wont help you.
>>
>> Gambas integer reserves one bit for sign and thus returned values are not correctly displayed in Gambas side.
>> However you can display them correctly by using binary representation.
>>
>>
>> Jussi
>>
>> On Sun, Jun 10, 2018 at 6:38 PM, Demosthenes Koptsis <demosthenesk at gmail.com <mailto:demosthenesk at gmail.com>> wrote:
>>
>>     hello,
>>
>>     i want to use an unsigned int in external function, which gambas datatype should i use?
>>
>>     Integer or Long?
>>
>>     The range of values is 0 to 4,294,967,295
>>
>>
>>     ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>>
>>
>>
>>
>> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
> 
> 
> 
> 
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
> 


More information about the User mailing list