[fpc-pascal] Documentation example error

Graeme Geldenhuys mailinglists at geldenhuys.co.uk
Tue Jan 26 10:58:39 CET 2016

On 2016-01-25 16:32, Michael Van Canneyt wrote:
> They should definitely be compilable.

To make the typeinfex/*.pp examples compilable, I had to make some
changes as shown below. I don't hope text wrapping screws this up, but
just in case, I attached the patch too. Before, it seems it was valid to
typecast a Set as Integer(), but testing with FPC 3.0 it seems
typecasting as Byte() is now required.

If I don't, the compile gives the following error:

   ex8.pp(25,17) Error: Illegal type conversion: "LongInt" to "TMyEnums"

Do you know when this change was made in FPC, and where it is documented
(eg: wiki User Changes ...)?

[typinfex (master)]$ git diff ex8.pp
diff --git a/typinfex/ex8.pp b/typinfex/ex8.pp
index 1a9d71e..e0c720c 100644
--- a/typinfex/ex8.pp
+++ b/typinfex/ex8.pp
@@ -20,9 +20,9 @@ begin
-  Writeln('SetToString (brackets) :
-  Writeln('SetToString (default)  : ',SetToString(Pi,Integer(O.SetField)));
-  O.SetField:=TMyEnums(StringToSet(PI,ConstSet));
-  Writeln('Stringtoset            : ',SetToString(PI,Integer(O.SetField)));
+  Writeln('SetToString (brackets) :
+  Writeln('SetToString (default)  : ',SetToString(Pi,Byte(O.SetField)));
+  O.SetField := TMyEnums(Byte(StringToSet(PI,ConstSet)));
+  Writeln('StringToSet            : ',SetToString(PI,Byte(O.SetField)));

  - Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal

My public PGP key:  http://tinyurl.com/graeme-pgp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: typeinfex_ex8.pp.patch
Type: text/x-patch
Size: 841 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20160126/642cb88b/attachment.bin>

More information about the fpc-pascal mailing list