[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Size of SET type
From: |
Gaius Mulley |
Subject: |
Re: Size of SET type |
Date: |
Sat, 25 Mar 2023 22:33:44 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) |
TELEMAQUE Olivier <olivier.telemaque@alstomgroup.com> writes:
> Hi,
>
>
>
> I have the code below :
>
>
>
> MODULE My_Module;
>
>
>
> FROM SYSTEM IMPORT SIZE;
>
> FROM libc IMPORT printf;
>
>
>
> TYPE Byte_T = SET OF [0..7];
>
> BEGIN
>
> printf("SIZE Byte_T = %u\n", SIZE(Byte_T));
>
> END My_Module.
>
>
>
> I expected to have SIZE Byte_T = 1 but unfortunately SIZE Byte_T = 4. Is it
> the behavior expected from Gm2 or is it a bug ?
>
>
>
> Regards,
>
> Olivier
Hi Olivier,
it is expected, if you want a one byte set you could use the reserved
word packedset, for example:
module setsize ;
from SYSTEM import size;
from libc import printf;
type
Byte_T = set of [0..7];
Small_Set_T = packedset of [0..7] ;
begin
printf("SIZE Byte_T = %u\n", size(Byte_T));
printf("SIZE Small_Set_T = %u\n", size(Small_Set_T));
end setsize.
$ gm2 -g setsize.mod
$ ./a.out
SIZE Byte_T = 4
SIZE Small_Set_T = 1
hope this helps,
regards,
Gaius