[fpc-pascal] Range check error warning.

Sven Barth pascaldragon at googlemail.com
Wed Mar 25 23:26:43 CET 2020


<wkitty42 at windstream.net> schrieb am Mi., 25. März 2020, 19:48:

> On 3/25/20 2:17 PM, Sven Barth via fpc-pascal wrote:
> > wkitty42 at windstream.net schrieb am Mi., 25. März 2020, 18:47:
> >
> >> hummm... ok, so how to you get a constant to be a byte and storing 7
> for the
> >> decimal value?
> >
> >
> > The compiler normally uses the smallest possible type that can represent
> the
> > value. You can force it however by using e.g.
> >
> > const
> >    MyConst = Word(42);
>
>
> ok... so in the situation this thread is covering:
>
> const
>    foldhiddenbit = byte(7);
>    foldhiddenmask = byte(1 shl foldhiddenbit);
>    currentfoldhiddenbit = byte(6);
>    currentfoldhiddenmask = byte(1 shl currentfoldhiddenbit);
>    foldlevelmask = byte(not (foldhiddenmask or currentfoldhiddenmask));
>
> is the way to do it?
>

In theory, yes, but for some reason the "not" upsets this. I have yet to
investigate why though and whether this is by design.

Regards,
Sven

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20200325/c0deff17/attachment-0001.html>


More information about the fpc-pascal mailing list